rethinkdb.rb 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. module Docs
  2. class Rethinkdb < UrlScraper
  3. self.name = 'RethinkDB'
  4. self.type = 'rethinkdb'
  5. self.base_url = 'https://rethinkdb.com/'
  6. self.release = '2.4.1'
  7. self.root_path = 'docs/'
  8. self.links = {
  9. home: 'https://rethinkdb.com/',
  10. code: 'https://github.com/rethinkdb/rethinkdb'
  11. }
  12. html_filters.push 'rethinkdb/entries', 'rethinkdb/clean_html'
  13. options[:trailing_slash] = true
  14. options[:container] = '.documentation'
  15. options[:only_patterns] = [/\Adocs/]
  16. options[:skip_patterns] = [/docs\/install(\-drivers)?\/./]
  17. options[:skip] = %w(
  18. docs/build/
  19. docs/tutorials/elections/
  20. docs/tutorials/superheroes/)
  21. MULTILANG_DOCS = %w(
  22. changefeeds
  23. cookbook
  24. dates-and-times
  25. geo-support
  26. guide
  27. nested-fields
  28. publish-subscribe
  29. rabbitmq
  30. secondary-indexes
  31. sql-to-reql
  32. storing-binary)
  33. options[:attribution] = <<-HTML
  34. &copy; RethinkDB contributors<br>
  35. Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
  36. HTML
  37. %w(JavaScript Ruby Python Java).each do |name|
  38. path = name.downcase
  39. instance_eval <<-CODE
  40. version '#{name}' do
  41. self.initial_paths = %w(api/#{path}/)
  42. options[:only_patterns] += [/\\Aapi\\/#{path}\\//]
  43. options[:fix_urls] = ->(url) do
  44. url.sub! %r{rethinkdb.com/docs/(#{MULTILANG_DOCS.join('|')})\\z}, 'rethinkdb.com/docs/\\1/#{path}/'
  45. url.sub! %r{rethinkdb.com/docs/(#{MULTILANG_DOCS.join('|')})/(?!#{path}/).*}, 'rethinkdb.com/docs/\\1/#{path}/'
  46. url.sub! %r{rethinkdb.com/api/(?!javascript|ruby|python|java)}, 'rethinkdb.com/api/#{path}/'
  47. url
  48. end
  49. end
  50. CODE
  51. end
  52. def get_latest_version(opts)
  53. get_latest_github_release('rethinkdb', 'rethinkdb', opts)
  54. end
  55. private
  56. def process_response?(response)
  57. return false unless super
  58. response.body !~ /http-equiv="refresh"/i
  59. end
  60. end
  61. end