postgresql.rb 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. module Docs
  2. class Postgresql < UrlScraper
  3. include FixInternalUrlsBehavior
  4. self.name = 'PostgreSQL'
  5. self.type = 'postgres'
  6. self.root_path = 'reference.html'
  7. self.initial_paths = %w(sql.html admin.html internals.html appendixes.html tutorial.html)
  8. self.links = {
  9. home: 'https://www.postgresql.org/',
  10. code: 'https://git.postgresql.org/gitweb/?p=postgresql.git'
  11. }
  12. html_filters.insert_before 'normalize_urls', 'postgresql/extract_metadata'
  13. html_filters.push 'postgresql/clean_html', 'postgresql/entries', 'title'
  14. options[:title] = false
  15. options[:root_title] = 'PostgreSQL'
  16. options[:follow_links] = ->(filter) { filter.initial_page? }
  17. options[:rate_limit] = 200
  18. options[:skip] = %w(
  19. index.html
  20. ddl-others.html
  21. functions-event-triggers.html
  22. functions-trigger.html
  23. textsearch-migration.html
  24. supported-platforms.html
  25. error-message-reporting.html
  26. error-style-guide.html
  27. plhandler.html
  28. sourcerepo.html
  29. git.html
  30. bug-reporting.html
  31. client-interfaces.html)
  32. options[:skip_patterns] = [
  33. /\Ainstall/,
  34. /\Aregress/,
  35. /\Aprotocol/,
  36. /\Asource/,
  37. /\Anls/,
  38. /\Afdw/,
  39. /\Atablesample/,
  40. /\Acustom-scan/,
  41. /\Abki/,
  42. /\Arelease/,
  43. /\Acontrib-prog/,
  44. /\Aexternal/,
  45. /\Adocguide/,
  46. /\Afeatures/,
  47. /\Aunsupported-features/ ]
  48. options[:attribution] = <<-HTML
  49. &copy; 1996&ndash;2025 The PostgreSQL Global Development Group<br>
  50. Licensed under the PostgreSQL License.
  51. HTML
  52. version '17' do
  53. self.release = '17.5'
  54. self.base_url = "https://www.postgresql.org/docs/#{version}/"
  55. end
  56. version '16' do
  57. self.release = '16.1'
  58. self.base_url = "https://www.postgresql.org/docs/#{version}/"
  59. end
  60. version '15' do
  61. self.release = '15.4'
  62. self.base_url = "https://www.postgresql.org/docs/#{version}/"
  63. end
  64. version '14' do
  65. self.release = '14.5'
  66. self.base_url = "https://www.postgresql.org/docs/#{version}/"
  67. end
  68. version '13' do
  69. self.release = '13.4'
  70. self.base_url = "https://www.postgresql.org/docs/#{version}/"
  71. end
  72. version '12' do
  73. self.release = '12.1'
  74. self.base_url = "https://www.postgresql.org/docs/#{version}/"
  75. end
  76. version '11' do
  77. self.release = '11.6'
  78. self.base_url = "https://www.postgresql.org/docs/#{version}/"
  79. end
  80. version '10' do
  81. self.release = '10.11'
  82. self.base_url = "https://www.postgresql.org/docs/#{version}/"
  83. end
  84. version '9.6' do
  85. self.release = '9.6.16'
  86. self.base_url = "https://www.postgresql.org/docs/#{version}/"
  87. html_filters.insert_before 'postgresql/extract_metadata', 'postgresql/normalize_class_names'
  88. end
  89. version '9.5' do
  90. self.release = '9.5.20'
  91. self.base_url = "https://www.postgresql.org/docs/#{version}/"
  92. html_filters.insert_before 'postgresql/extract_metadata', 'postgresql/normalize_class_names'
  93. end
  94. version '9.4' do
  95. self.release = '9.4.25'
  96. self.base_url = "https://www.postgresql.org/docs/#{version}/"
  97. html_filters.insert_before 'postgresql/extract_metadata', 'postgresql/normalize_class_names'
  98. end
  99. def get_latest_version(opts)
  100. doc = fetch_doc('https://www.postgresql.org/docs/current/index.html', opts)
  101. label = doc.at_css('#pgContentWrap h1.title').content
  102. label.scan(/([0-9.]+)/)[0][0]
  103. end
  104. end
  105. end