1
0

openjdk.rb 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. module Docs
  2. class Openjdk < FileScraper
  3. self.name = 'OpenJDK'
  4. self.type = 'openjdk'
  5. self.root_path = 'overview-summary.html'
  6. self.links = {
  7. home: 'https://openjdk.java.net/',
  8. code: 'https://github.com/openjdk/jdk'
  9. }
  10. html_filters.insert_after 'internal_urls', 'openjdk/clean_urls'
  11. options[:skip_patterns] = [
  12. /compact[123]-/,
  13. /package-frame\.html/,
  14. /package-tree\.html/,
  15. /package-use\.html/,
  16. /class-use\//,
  17. /doc-files\//,
  18. /\.svg/,
  19. /\.png/
  20. ]
  21. options[:only_patterns] = [/\Ajava\./]
  22. options[:attribution] = <<-HTML
  23. &copy; 1993, 2020, Oracle and/or its affiliates. All rights reserved.<br>
  24. Documentation extracted from Debian's OpenJDK Development Kit package.<br>
  25. Licensed under the GNU General Public License, version 2, with the Classpath Exception.<br>
  26. Various third party code in OpenJDK is licensed under different licenses (see Debian package).<br>
  27. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
  28. HTML
  29. NEWFILTERS = ['openjdk/entries_new', 'openjdk/clean_html_new']
  30. version '15' do
  31. self.release = '15.0.1'
  32. self.root_path = 'index.html'
  33. html_filters.push NEWFILTERS
  34. options[:container] = 'main'
  35. end
  36. OLDFILTERS = ['openjdk/entries', 'openjdk/clean_html']
  37. version '11' do
  38. self.release = '11.0.9'
  39. self.root_path = 'index.html'
  40. self.base_url = 'https://docs.oracle.com/en/java/javase/11/docs/api/'
  41. html_filters.push OLDFILTERS
  42. end
  43. version '8' do
  44. self.release = '8'
  45. html_filters.push OLDFILTERS
  46. options[:only_patterns] = [
  47. /\Ajava\/beans\//,
  48. /\Ajava\/io\//,
  49. /\Ajava\/lang\//,
  50. /\Ajava\/math\//,
  51. /\Ajava\/net\//,
  52. /\Ajava\/nio\//,
  53. /\Ajava\/security\//,
  54. /\Ajava\/text\//,
  55. /\Ajava\/time\//,
  56. /\Ajava\/util\//,
  57. /\Ajavax\/annotation\//,
  58. /\Ajavax\/crypto\//,
  59. /\Ajavax\/imageio\//,
  60. /\Ajavax\/lang\//,
  61. /\Ajavax\/management\//,
  62. /\Ajavax\/naming\//,
  63. /\Ajavax\/net\//,
  64. /\Ajavax\/print\//,
  65. /\Ajavax\/script\//,
  66. /\Ajavax\/security\//,
  67. /\Ajavax\/sound\//,
  68. /\Ajavax\/tools\//
  69. ]
  70. end
  71. version '8 GUI' do
  72. self.release = '8'
  73. html_filters.push OLDFILTERS
  74. options[:only_patterns] = [
  75. /\Ajava\/awt\//,
  76. /\Ajavax\/swing\//
  77. ]
  78. end
  79. version '8 Web' do
  80. self.release = '8'
  81. html_filters.push OLDFILTERS
  82. options[:only_patterns] = [
  83. /\Ajava\/applet\//,
  84. /\Ajava\/rmi\//,
  85. /\Ajava\/sql\//,
  86. /\Ajavax\/accessibility\//,
  87. /\Ajavax\/activation\//,
  88. /\Ajavax\/activity\//,
  89. /\Ajavax\/jws\//,
  90. /\Ajavax\/rmi\//,
  91. /\Ajavax\/sql\//,
  92. /\Ajavax\/transaction\//,
  93. /\Ajavax\/xml\//,
  94. /\Aorg\/ietf\//,
  95. /\Aorg\/omg\//,
  96. /\Aorg\/w3c\//,
  97. /\Aorg\/xml\//]
  98. end
  99. # Monkey patch to properly read HTML files encoded in ISO-8859-1
  100. def read_file(path)
  101. File.read(path).force_encoding('iso-8859-1').encode('utf-8') rescue nil
  102. end
  103. def get_latest_version(opts)
  104. latest_version = 8
  105. current_attempt = latest_version
  106. attempts = 0
  107. while attempts < 3
  108. current_attempt += 1
  109. doc = fetch_doc("https://packages.debian.org/sid/openjdk-#{current_attempt}-doc", opts)
  110. if doc.at_css('.perror').nil?
  111. latest_version = current_attempt
  112. attempts = 0
  113. else
  114. attempts += 1
  115. end
  116. end
  117. latest_version
  118. end
  119. end
  120. end