postgresql.rb 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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[:skip] = %w(
  18. index.html
  19. ddl-others.html
  20. functions-event-triggers.html
  21. functions-trigger.html
  22. textsearch-migration.html
  23. supported-platforms.html
  24. error-message-reporting.html
  25. error-style-guide.html
  26. plhandler.html
  27. sourcerepo.html
  28. git.html
  29. bug-reporting.html
  30. client-interfaces.html)
  31. options[:skip_patterns] = [
  32. /\Ainstall/,
  33. /\Aregress/,
  34. /\Aprotocol/,
  35. /\Asource/,
  36. /\Anls/,
  37. /\Afdw/,
  38. /\Atablesample/,
  39. /\Acustom-scan/,
  40. /\Abki/,
  41. /\Arelease/,
  42. /\Acontrib-prog/,
  43. /\Aexternal/,
  44. /\Adocguide/,
  45. /\Afeatures/,
  46. /\Aunsupported-features/ ]
  47. options[:attribution] = <<-HTML
  48. &copy; 1996&ndash;2022 The PostgreSQL Global Development Group<br>
  49. Licensed under the PostgreSQL License.
  50. HTML
  51. version '15' do
  52. self.release = '15.0'
  53. self.base_url = "https://www.postgresql.org/docs/#{version}/"
  54. end
  55. version '14' do
  56. self.release = '14.5'
  57. self.base_url = "https://www.postgresql.org/docs/#{version}/"
  58. end
  59. version '13' do
  60. self.release = '13.4'
  61. self.base_url = "https://www.postgresql.org/docs/#{version}/"
  62. end
  63. version '12' do
  64. self.release = '12.1'
  65. self.base_url = "https://www.postgresql.org/docs/#{version}/"
  66. end
  67. version '11' do
  68. self.release = '11.6'
  69. self.base_url = "https://www.postgresql.org/docs/#{version}/"
  70. end
  71. version '10' do
  72. self.release = '10.11'
  73. self.base_url = "https://www.postgresql.org/docs/#{version}/"
  74. end
  75. version '9.6' do
  76. self.release = '9.6.16'
  77. self.base_url = "https://www.postgresql.org/docs/#{version}/"
  78. html_filters.insert_before 'postgresql/extract_metadata', 'postgresql/normalize_class_names'
  79. end
  80. version '9.5' do
  81. self.release = '9.5.20'
  82. self.base_url = "https://www.postgresql.org/docs/#{version}/"
  83. html_filters.insert_before 'postgresql/extract_metadata', 'postgresql/normalize_class_names'
  84. end
  85. version '9.4' do
  86. self.release = '9.4.25'
  87. self.base_url = "https://www.postgresql.org/docs/#{version}/"
  88. html_filters.insert_before 'postgresql/extract_metadata', 'postgresql/normalize_class_names'
  89. end
  90. def get_latest_version(opts)
  91. doc = fetch_doc('https://www.postgresql.org/docs/current/index.html', opts)
  92. label = doc.at_css('#pgContentWrap h1.title').content
  93. label.scan(/([0-9.]+)/)[0][0]
  94. end
  95. end
  96. end