postgresql.rb 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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;2019 The PostgreSQL Global Development Group<br>
  49. Licensed under the PostgreSQL License.
  50. HTML
  51. version '11' do
  52. self.release = '11.5'
  53. self.base_url = 'https://www.postgresql.org/docs/11/'
  54. end
  55. version '10' do
  56. self.release = '10.3'
  57. self.base_url = 'https://www.postgresql.org/docs/10/static/'
  58. end
  59. version '9.6' do
  60. self.release = '9.6.6'
  61. self.base_url = 'https://www.postgresql.org/docs/9.6/static/'
  62. html_filters.insert_before 'postgresql/extract_metadata', 'postgresql/normalize_class_names'
  63. end
  64. version '9.5' do
  65. self.release = '9.5.10'
  66. self.base_url = 'https://www.postgresql.org/docs/9.5/static/'
  67. html_filters.insert_before 'postgresql/extract_metadata', 'postgresql/normalize_class_names'
  68. end
  69. version '9.4' do
  70. self.release = '9.4.15'
  71. self.base_url = 'https://www.postgresql.org/docs/9.4/static/'
  72. html_filters.insert_before 'postgresql/extract_metadata', 'postgresql/normalize_class_names'
  73. end
  74. def get_latest_version(opts)
  75. doc = fetch_doc('https://www.postgresql.org/docs/current/index.html', opts)
  76. label = doc.at_css('#pgContentWrap h1.title').content
  77. label.scan(/([0-9.]+)/)[0][0]
  78. end
  79. end
  80. end