Browse Source

Fix and improve openjdk's get_latest_version

Enoc 4 năm trước cách đây
mục cha
commit
3efd73ae40
1 tập tin đã thay đổi với 5 bổ sung17 xóa
  1. 5 17
      lib/docs/scrapers/openjdk.rb

+ 5 - 17
lib/docs/scrapers/openjdk.rb

@@ -132,23 +132,11 @@ module Docs
     end
 
     def get_latest_version(opts)
-      latest_version = 8
-      current_attempt = latest_version
-      attempts = 0
-
-      while attempts < 3
-        current_attempt += 1
-
-        doc = fetch_doc("https://packages.debian.org/sid/openjdk-#{current_attempt}-doc", opts)
-        if doc.at_css('.perror').nil?
-          latest_version = current_attempt
-          attempts = 0
-        else
-          attempts += 1
-        end
-      end
-
-      latest_version
+      doc = fetch_doc("https://jdk.java.net/archive/", opts)
+      puts doc
+      version = doc.at_css('#downloads > table > tr > th').content
+      version.gsub!(/\(.*\)/, '')
+      version.gsub!(/[a-zA-z]/, '')
     end
   end
 end