Ver código fonte

Fix broken get_latest_version implementations

Jasper van Merle 5 anos atrás
pai
commit
f1b464b1ed

+ 1 - 1
lib/docs/scrapers/ansible.rb

@@ -71,7 +71,7 @@ module Docs
 
     def get_latest_version(opts)
       doc = fetch_doc('https://docs.ansible.com/ansible/latest/index.html', opts)
-      doc.at_css('.DocSiteProduct-CurrentVersion').content.strip
+      doc.at_css('.version').content.strip
     end
   end
 end

+ 1 - 2
lib/docs/scrapers/babel.rb

@@ -24,8 +24,7 @@ module Docs
     end
 
     def get_latest_version(opts)
-      doc = fetch_doc('https://babeljs.io/docs/en/', opts)
-      doc.at_css('a[href="/versions"] > h3').content
+      get_latest_github_release('babel', 'babel', opts)
     end
   end
 end

+ 2 - 2
lib/docs/scrapers/chef.rb

@@ -49,8 +49,8 @@ module Docs
     end
 
     def get_latest_version(opts)
-      doc = fetch_doc('https://downloads.chef.io/chef', opts)
-      doc.at_css('h1.product-heading > span').content.strip
+      doc = fetch_doc('https://downloads.chef.io/products/infra', opts)
+      doc.at_css('#versions > option').content.strip
     end
   end
 end

+ 2 - 3
lib/docs/scrapers/codeigniter.rb

@@ -40,9 +40,8 @@ module Docs
     end
 
     def get_latest_version(opts)
-      doc = fetch_doc('https://codeigniter.com/user_guide/changelog.html', opts)
-      header = doc.at_css('#change-log h2')
-      header.content.scan(/([0-9.]+)/)[0][0]
+      tags = get_github_tags('codeigniter4', 'codeigniter4', opts)
+      tags[0]['name'][1..-1]
     end
   end
 end

+ 1 - 2
lib/docs/scrapers/dart.rb

@@ -32,8 +32,7 @@ module Docs
 
     def get_latest_version(opts)
       doc = fetch_doc('https://api.dartlang.org/', opts)
-      label = doc.at_css('footer > span').content.strip
-      label.sub(/Dart /, '')
+      doc.at_css('footer > span').content.sub(/Dart/, '').strip
     end
   end
 end

+ 3 - 3
lib/docs/scrapers/docker.rb

@@ -260,9 +260,9 @@ module Docs
     end
 
     def get_latest_version(opts)
-      doc = fetch_doc('https://docs.docker.com/', opts)
-      label = doc.at_css('.nav-container button.dropdown-toggle').content.strip
-      label.scan(/([0-9.]+)/)[0][0]
+      doc = fetch_doc('https://docs.docker.com/engine/release-notes/', opts)
+      latest_version = doc.at_css('.content > section > h1[id^="version-"]').content.strip
+      latest_version.rpartition(' ')[-1]
     end
   end
 end

+ 1 - 1
lib/docs/scrapers/elixir.rb

@@ -126,7 +126,7 @@ module Docs
 
     def get_latest_version(opts)
       doc = fetch_doc('https://hexdocs.pm/elixir/api-reference.html', opts)
-      doc.at_css('h2.sidebar-projectVersion').content.strip[1..-1]
+      doc.at_css('.sidebar-projectVersion').content.strip[1..-1]
     end
   end
 end

+ 1 - 2
lib/docs/scrapers/erlang.rb

@@ -57,8 +57,7 @@ module Docs
     end
 
     def get_latest_version(opts)
-      doc = fetch_doc('https://www.erlang.org/downloads', opts)
-      doc.at_css('.col-lg-3 > ul > li').content.strip.sub(/OTP /, '')
+      get_latest_github_release('erlang', 'otp', opts)[4..-1]
     end
   end
 end

+ 1 - 2
lib/docs/scrapers/fish.rb

@@ -54,8 +54,7 @@ module Docs
     end
 
     def get_latest_version(opts)
-      doc = fetch_doc('http://fishshell.com/docs/current/index.html', opts)
-      doc.at_css('#toc-index').content.scan(/([0-9.]+)/)[0][0]
+      get_latest_github_release('fish-shell', 'fish-shell', opts)
     end
   end
 end

+ 5 - 3
lib/docs/scrapers/gnu_cobol.rb

@@ -18,9 +18,11 @@ module Docs
     HTML
 
     def get_latest_version(opts)
-      doc = fetch_doc('https://open-cobol.sourceforge.io/HTML/gnucobpg.html', opts)
-      title = doc.at_css('h1').content
-      title.scan(/([0-9.]+)/)[0][0]
+      fetch_doc('https://sourceforge.net/projects/gnucobol/files/gnucobol/', opts)
+        .css('#files_list > tbody > tr')
+        .map { |file| file['title'] }
+        .sort_by { |version| version.to_f }
+        .last
     end
   end
 end

+ 4 - 0
lib/docs/scrapers/gnuplot.rb

@@ -37,5 +37,9 @@ module Docs
       Distributed under the <a href="https://sourceforge.net/p/gnuplot/gnuplot-main/ci/master/tree/Copyright">gnuplot license</a> (rights to distribute modified versions are withheld).
     HTML
 
+    def get_latest_version(opts)
+      doc = fetch_doc('https://sourceforge.net/projects/gnuplot/files/gnuplot/', opts)
+      doc.at_css('#files_list > tbody > tr:nth-child(2)')['title']
+    end
   end
 end

+ 1 - 2
lib/docs/scrapers/godot.rb

@@ -44,8 +44,7 @@ module Docs
     end
 
     def get_latest_version(opts)
-      doc = fetch_doc('https://docs.godotengine.org/', opts)
-      doc.at_css('.version').content.strip
+      get_latest_github_release('godotengine', 'godot', opts).split('-')[0]
     end
   end
 end

+ 1 - 3
lib/docs/scrapers/influxdata.rb

@@ -48,9 +48,7 @@ module Docs
     HTML
 
     def get_latest_version(opts)
-      doc = fetch_doc('https://docs.influxdata.com/influxdb/', opts)
-      label = doc.at_css('.navbar--current-product').content.strip
-      label.scan(/([0-9.]+)/)[0][0]
+      get_latest_github_release('influxdata', 'influxdb', opts)
     end
   end
 end

+ 1 - 2
lib/docs/scrapers/moment.rb

@@ -24,8 +24,7 @@ module Docs
     HTML
 
     def get_latest_version(opts)
-      doc = fetch_doc('http://momentjs.com/', opts)
-      doc.at_css('.hero-title > h1 > span').content
+      get_github_tags('moment', 'moment', opts)[0]['name']
     end
   end
 end

+ 1 - 2
lib/docs/scrapers/pandas.rb

@@ -63,8 +63,7 @@ module Docs
 
     def get_latest_version(opts)
       doc = fetch_doc('http://pandas.pydata.org/pandas-docs/stable/', opts)
-      label = doc.at_css('.body > .section > p').content
-      label.scan(/Version: ([0-9.]+)/)[0][0]
+      doc.at_css('#pandas-documentation').content.scan(/Version: ([0-9.]+)/)[0][0]
     end
   end
 end

+ 1 - 2
lib/docs/scrapers/perl.rb

@@ -46,8 +46,7 @@ module Docs
 
     def get_latest_version(opts)
       doc = fetch_doc('https://perldoc.perl.org/', opts)
-      header = doc.at_css('h2.h1').content
-      header.scan(/Perl ([0-9.]+)/)[0][0]
+      doc.at_css('#dropdownlink-stable').content
     end
   end
 end

+ 2 - 3
lib/docs/scrapers/php.rb

@@ -68,9 +68,8 @@ module Docs
     HTML
 
     def get_latest_version(opts)
-      doc = fetch_doc('https://secure.php.net/manual/en/doc.changelog.php', opts)
-      label = doc.at_css('tbody.gen-changelog > tr > td').content
-      label.split(',').last.strip
+      doc = fetch_doc('https://www.php.net/supported-versions.php', opts)
+      doc.at_css('table > tbody > .stable:last-of-type > td > a').content.strip
     end
   end
 end

+ 1 - 1
lib/docs/scrapers/python.rb

@@ -60,7 +60,7 @@ module Docs
 
     def get_latest_version(opts)
       doc = fetch_doc('https://docs.python.org/', opts)
-      doc.at_css('.version_switcher_placeholder').content
+      doc.at_css('title').content.split(' ')[0]
     end
   end
 end

+ 2 - 2
lib/docs/scrapers/react_native.rb

@@ -32,8 +32,8 @@ module Docs
     HTML
 
     def get_latest_version(opts)
-      doc = fetch_doc('https://facebook.github.io/react-native/docs/getting-started.html', opts)
-      doc.at_css('header > a > h3').content
+      doc = fetch_doc('https://reactnative.dev/docs/getting-started', opts)
+      doc.at_css('meta[name="docsearch:version"]')['content']
     end
   end
 end

+ 1 - 2
lib/docs/scrapers/scikit_learn.rb

@@ -26,8 +26,7 @@ module Docs
     HTML
 
     def get_latest_version(opts)
-      doc = fetch_doc('https://scikit-learn.org/stable/documentation.html', opts)
-      doc.at_css('.body h1').content.scan(/([0-9.]+)/)[0][0]
+      get_latest_github_release('scikit-learn', 'scikit-learn', opts)
     end
   end
 end

+ 1 - 2
lib/docs/scrapers/statsmodels.rb

@@ -22,8 +22,7 @@ module Docs
     HTML
 
     def get_latest_version(opts)
-      doc = fetch_doc('http://www.statsmodels.org/stable/', opts)
-      doc.at_css('.sphinxsidebarwrapper h3 + p > b').content[1..-1]
+      get_latest_github_release('statsmodels', 'statsmodels', opts)
     end
   end
 end

+ 1 - 2
lib/docs/scrapers/vagrant.rb

@@ -20,8 +20,7 @@ module Docs
     HTML
 
     def get_latest_version(opts)
-      contents = get_github_file_contents('hashicorp', 'vagrant', 'website/config.rb', opts)
-      contents.scan(/version\s+=\s+"([0-9.]+)"/)[0][0]
+      get_github_tags('hashicorp', 'vagrant', opts)[0]['name'][1..-1]
     end
   end
 end