1
0

openjdk.rb 3.0 KB

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