1
0

drupal.rb 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. module Docs
  2. class Drupal < UrlScraper
  3. self.type = 'drupal'
  4. self.base_url = 'https://api.drupal.org/api/drupal/'
  5. self.links = {
  6. home: 'https://www.drupal.org/',
  7. code: 'http://cgit.drupalcode.org/drupal'
  8. }
  9. html_filters.push 'drupal/entries', 'drupal/clean_html', 'title'
  10. options[:decode_and_clean_paths] = true
  11. options[:container] = '#page-inner'
  12. options[:title] = false
  13. options[:root_title] = 'Drupal'
  14. options[:skip_link] = ->(link) { link['href'] =~ /[\?&]order/ }
  15. options[:skip_patterns] = [
  16. /test/i,
  17. /_update_[0-9]{4}/,
  18. /\/group\/updates\-\d/,
  19. /interface\/implements/,
  20. /\/(class|interface|trait)\/hierarchy\//,
  21. /\/(class|interface|trait)\/uses\//,
  22. /\/(class|interface|trait)\/references\//,
  23. /\/(class|interface|trait)\/annotations\//,
  24. /\/function\/calls\//,
  25. /\/function\/invokes\//,
  26. /\/function\/overrides\//,
  27. /\/function\/references\//,
  28. /\/function\/implementations\//,
  29. /\/function\/theme_references\//,
  30. /upgrade/,
  31. /DRUPAL_ROOT/,
  32. /constant\/constants/,
  33. /theme_invokes/
  34. ]
  35. options[:attribution] = <<-HTML
  36. &copy; 2001&ndash;2016 by the original authors<br>
  37. Licensed under the GNU General Public License, version 2 and later.<br>
  38. Drupal is a registered trademark of Dries Buytaert.
  39. HTML
  40. version '8' do
  41. self.release = '8.1.7'
  42. self.root_path = '8.1.x'
  43. self.initial_paths = %w(groups/8.1.x groups/8.1.x?page=1)
  44. options[:only_patterns] = [
  45. /\/class\/[^\/]+\/8\.1\.x\z/,
  46. /\/group\/[^\/]+\/8\.1\.x\z/,
  47. /\/function\/[^\/]+\/8\.1\.x\z/,
  48. /\/constant\/[^\/]+\/8\.1\.x\z/,
  49. /\/interface\/[^\/]+\/8\.1\.x\z/,
  50. /\/property\/[^\/]+\/8\.1\.x\z/,
  51. /\/global\/[^\/]+\/8\.1\.x\z/,
  52. /\/trait\/[^\/]+\/8\.1\.x\z/,
  53. /modules.*\/8\.1\.x\z/,
  54. /includes.*\/8\.1\.x\z/,
  55. /\A[\w\-\.]+\.php\/8\.1\.x\z/
  56. ]
  57. options[:skip] = %w(index.php/8.1.x update.php/8.1.x)
  58. options[:skip_patterns] += [
  59. /[^\w\-\.].*\.php\/8\.1\.x\z/,
  60. /\!src\!/,
  61. /migrate/,
  62. /Assertion/,
  63. /listing_page/,
  64. /update_api/,
  65. /vendor/,
  66. /deprecated/,
  67. /namespace/,
  68. /\.yml/,
  69. /Plugin/,
  70. /\.theme\//
  71. ]
  72. end
  73. version '7' do
  74. self.release = '7.50'
  75. self.root_path = '7.x'
  76. self.initial_paths = %w(groups/7.x groups/7.x?page=1)
  77. options[:only_patterns] = [
  78. /\/class\/[^\/]+\/7\.x\z/,
  79. /\/group\/[^\/]+\/7\.x\z/,
  80. /\/function\/[^\/]+\/7\.x\z/,
  81. /\/constant\/[^\/]+\/7\.x\z/,
  82. /\/interface\/[^\/]+\/7\.x\z/,
  83. /\/property\/[^\/]+\/7\.x\z/,
  84. /\/global\/[^\/]+\/7\.x\z/,
  85. /modules.*\/7\.x\z/,
  86. /includes.*\/7\.x\z/,
  87. /\A[\w\-\.]+\.php\/7\.x\z/
  88. ]
  89. end
  90. def get_latest_version(opts)
  91. json = fetch_json('https://packagist.org/packages/drupal/drupal.json', opts)
  92. json['package']['versions'].keys.find {|version| !version.end_with?('-dev')}
  93. end
  94. end
  95. end