1
0

node.rb 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. module Docs
  2. class Node < UrlScraper
  3. self.name = 'Node.js'
  4. self.slug = 'node'
  5. self.type = 'node'
  6. self.links = {
  7. home: 'https://nodejs.org/',
  8. code: 'https://github.com/nodejs/node'
  9. }
  10. html_filters.push 'node/clean_html', 'node/entries', 'title'
  11. options[:title] = false
  12. options[:root_title] = 'Node.js'
  13. options[:container] = '#apicontent'
  14. options[:skip] = %w(index.html all.html documentation.html synopsis.html)
  15. options[:attribution] = <<-HTML
  16. &copy; Joyent, Inc. and other Node contributors<br>
  17. Licensed under the MIT License.<br>
  18. Node.js is a trademark of Joyent, Inc. and is used with its permission.<br>
  19. We are not endorsed by or affiliated with Joyent.
  20. HTML
  21. version do
  22. self.release = '15.5.0'
  23. self.base_url = 'https://nodejs.org/dist/latest-v15.x/docs/api/'
  24. end
  25. version '14 LTS' do
  26. self.release = '14.15.3'
  27. self.base_url = 'https://nodejs.org/dist/latest-v14.x/docs/api/'
  28. end
  29. version '12 LTS' do
  30. self.release = '12.19.0'
  31. self.base_url = 'https://nodejs.org/dist/latest-v12.x/docs/api/'
  32. end
  33. version '10 LTS' do
  34. self.release = '10.16.3'
  35. self.base_url = 'https://nodejs.org/dist/latest-v10.x/docs/api/'
  36. end
  37. version '8 LTS' do
  38. self.release = '8.16.1'
  39. self.base_url = 'https://nodejs.org/dist/latest-v8.x/docs/api/'
  40. end
  41. version '6 LTS' do
  42. self.release = '6.14.4'
  43. self.base_url = 'https://nodejs.org/dist/latest-v6.x/docs/api/'
  44. end
  45. version '4 LTS' do
  46. self.release = '4.9.1'
  47. self.base_url = 'https://nodejs.org/dist/latest-v4.x/docs/api/'
  48. end
  49. def get_latest_version(opts)
  50. doc = fetch_doc('https://nodejs.org/en/', opts)
  51. doc.at_css('#home-intro > .home-downloadblock:last-of-type > a')['data-version'][1..-1]
  52. end
  53. end
  54. end