1
0

angular.rb 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. module Docs
  2. class Angular < UrlScraper
  3. self.name = 'Angular.js'
  4. self.slug = 'angular'
  5. self.type = 'angular'
  6. self.root_path = 'api.html'
  7. self.initial_paths = %w(guide.html)
  8. html_filters.push 'angular/clean_html', 'angular/entries', 'title'
  9. text_filters.push 'angular/clean_urls'
  10. options[:title] = false
  11. options[:root_title] = 'Angular.js'
  12. options[:decode_and_clean_paths] = true
  13. options[:fix_urls_before_parse] = ->(str) do
  14. str.gsub!('[', '%5B')
  15. str.gsub!(']', '%5D')
  16. str
  17. end
  18. options[:fix_urls] = ->(url) do
  19. %w(api guide).each do |str|
  20. url.sub! "/partials/#{str}/#{str}/", "/partials/#{str}/"
  21. url.sub! %r{/#{str}/img/}, "/img/"
  22. url.sub! %r{/#{str}/(.+?)/#{str}/}, "/#{str}/"
  23. url.sub! %r{/partials/#{str}/(.+?)(?<!\.html)(?:\z|(#.*))}, "/partials/#{str}/\\1.html\\2"
  24. end
  25. url
  26. end
  27. options[:only_patterns] = [%r{\Aapi/}, %r{\Aguide/}]
  28. options[:skip] = %w(api/ng.html)
  29. options[:attribution] = <<-HTML
  30. &copy; 2010&ndash;2016 Google, Inc.<br>
  31. Licensed under the Creative Commons Attribution License 4.0.
  32. HTML
  33. version '1.5' do
  34. self.release = '1.5.3'
  35. self.base_url = "https://code.angularjs.org/#{release}/docs/partials/"
  36. end
  37. version '1.4' do
  38. self.release = '1.4.10'
  39. self.base_url = "https://code.angularjs.org/#{release}/docs/partials/"
  40. end
  41. version '1.3' do
  42. self.release = '1.3.20'
  43. self.base_url = "https://code.angularjs.org/#{release}/docs/partials/"
  44. end
  45. version '1.2' do
  46. self.release = '1.2.29'
  47. self.base_url = "https://code.angularjs.org/#{release}/docs/partials/"
  48. end
  49. stub '' do
  50. require 'capybara/dsl'
  51. Capybara.current_driver = :selenium
  52. Capybara.run_server = false
  53. Capybara.app_host = 'https://code.angularjs.org'
  54. Capybara.visit("/#{self.class.release}/docs/api")
  55. Capybara.find('.side-navigation')['innerHTML']
  56. end
  57. end
  58. end