History

Merge pull request #1294 from jmerle/fix-update-checks

Fix broken get_latest_version implementations

Simon Legner committed 5 years ago

Commit 18f5c0a2 parents 7976b04 7ca18dd19 files · +28 −40Browse files

Unified · Split

19 files
  1. lib/docs/scrapers/babel.rb +1 −2
  2. lib/docs/scrapers/chef.rb +2 −2
  3. lib/docs/scrapers/codeigniter.rb +2 −3
  4. lib/docs/scrapers/docker.rb +3 −3
  5. lib/docs/scrapers/elixir.rb +1 −1
  6. lib/docs/scrapers/erlang.rb +1 −2
  7. lib/docs/scrapers/fish.rb +1 −2
  8. lib/docs/scrapers/gnu_cobol.rb +5 −3
  9. lib/docs/scrapers/gnuplot.rb +0 −1
  10. lib/docs/scrapers/godot.rb +1 −2
  11. lib/docs/scrapers/influxdata.rb +1 −3
  12. lib/docs/scrapers/moment.rb +1 −2
  13. lib/docs/scrapers/perl.rb +1 −2
  14. lib/docs/scrapers/php.rb +2 −3
  15. lib/docs/scrapers/python.rb +1 −1
  16. lib/docs/scrapers/react_native.rb +2 −2
  17. lib/docs/scrapers/scikit_learn.rb +1 −2
  18. lib/docs/scrapers/statsmodels.rb +1 −2
  19. lib/docs/scrapers/vagrant.rb +1 −2
lib/docs/scrapers/babel.rb+1−2
@@ -24,8 +24,7 @@ module Docs · 23 unmodified lines
2424 end
2525
2626 def get_latest_version(opts)
27− doc = fetch_doc('https://babeljs.io/docs/en/', opts)
28− doc.at_css('a[href="/versions"] > h3').content
27+ get_latest_github_release('babel', 'babel', opts)
2928 end
3029 end
3130 end
lib/docs/scrapers/chef.rb+2−2
@@ -49,8 +49,8 @@ module Docs · 48 unmodified lines
4949 end
5050
5151 def get_latest_version(opts)
52− doc = fetch_doc('https://downloads.chef.io/chef', opts)
53− doc.at_css('h1.product-heading > span').content.strip
52+ doc = fetch_doc('https://downloads.chef.io/products/infra', opts)
53+ doc.at_css('#versions > option').content.strip
5454 end
5555 end
5656 end
lib/docs/scrapers/codeigniter.rb+2−3
@@ -40,9 +40,8 @@ module Docs · 39 unmodified lines
4040 end
4141
4242 def get_latest_version(opts)
43− doc = fetch_doc('https://codeigniter.com/user_guide/changelog.html', opts)
44− header = doc.at_css('#change-log h2')
45− header.content.scan(/([0-9.]+)/)[0][0]
43+ tags = get_github_tags('codeigniter4', 'codeigniter4', opts)
44+ tags[0]['name'][1..-1]
4645 end
4746 end
4847 end
lib/docs/scrapers/docker.rb+3−3
@@ -260,9 +260,9 @@ module Docs · 259 unmodified lines
260260 end
261261
262262 def get_latest_version(opts)
263− doc = fetch_doc('https://docs.docker.com/', opts)
264− label = doc.at_css('.nav-container button.dropdown-toggle').content.strip
265− label.scan(/([0-9.]+)/)[0][0]
263+ doc = fetch_doc('https://docs.docker.com/engine/release-notes/', opts)
264+ latest_version = doc.at_css('.content > section > h1[id^="version-"]').content.strip
265+ latest_version.rpartition(' ')[-1]
266266 end
267267 end
268268 end
lib/docs/scrapers/elixir.rb+1−1
@@ -126,7 +126,7 @@ module Docs · 125 unmodified lines
126126
127127 def get_latest_version(opts)
128128 doc = fetch_doc('https://hexdocs.pm/elixir/api-reference.html', opts)
129− doc.at_css('h2.sidebar-projectVersion').content.strip[1..-1]
129+ doc.at_css('.sidebar-projectVersion').content.strip[1..-1]
130130 end
131131 end
132132 end
lib/docs/scrapers/erlang.rb+1−2
@@ -57,8 +57,7 @@ module Docs · 56 unmodified lines
5757 end
5858
5959 def get_latest_version(opts)
60− doc = fetch_doc('https://www.erlang.org/downloads', opts)
61− doc.at_css('.col-lg-3 > ul > li').content.strip.sub(/OTP /, '')
60+ get_latest_github_release('erlang', 'otp', opts)[4..-1]
6261 end
6362 end
6463 end
lib/docs/scrapers/fish.rb+1−2
@@ -54,8 +54,7 @@ module Docs · 53 unmodified lines
5454 end
5555
5656 def get_latest_version(opts)
57− doc = fetch_doc('http://fishshell.com/docs/current/index.html', opts)
58− doc.at_css('#toc-index').content.scan(/([0-9.]+)/)[0][0]
57+ get_latest_github_release('fish-shell', 'fish-shell', opts)
5958 end
6059 end
6160 end
lib/docs/scrapers/gnu_cobol.rb+5−3
@@ -18,9 +18,11 @@ module Docs · 17 unmodified lines
1818 HTML
1919
2020 def get_latest_version(opts)
21− doc = fetch_doc('https://open-cobol.sourceforge.io/HTML/gnucobpg.html', opts)
22− title = doc.at_css('h1').content
23− title.scan(/([0-9.]+)/)[0][0]
21+ fetch_doc('https://sourceforge.net/projects/gnucobol/files/gnucobol/', opts)
22+ .css('#files_list > tbody > tr')
23+ .map { |file| file['title'] }
24+ .sort_by { |version| version.to_f }
25+ .last
2426 end
2527 end
2628 end
lib/docs/scrapers/gnuplot.rb+0−1
@@ -42,6 +42,5 @@ module Docs · 41 unmodified lines
4242 label = doc.at_css('h2').content.strip
4343 label.sub(/[^0-9.]*/, '')
4444 end
45−
4645 end
4746 end
lib/docs/scrapers/godot.rb+1−2
@@ -44,8 +44,7 @@ module Docs · 43 unmodified lines
4444 end
4545
4646 def get_latest_version(opts)
47− doc = fetch_doc('https://docs.godotengine.org/', opts)
48− doc.at_css('.version').content.strip
47+ get_latest_github_release('godotengine', 'godot', opts).split('-')[0]
4948 end
5049 end
5150 end
lib/docs/scrapers/influxdata.rb+1−3
@@ -48,9 +48,7 @@ module Docs · 47 unmodified lines
4848 HTML
4949
5050 def get_latest_version(opts)
51− doc = fetch_doc('https://docs.influxdata.com/influxdb/', opts)
52− label = doc.at_css('.navbar--current-product').content.strip
53− label.scan(/([0-9.]+)/)[0][0]
51+ get_latest_github_release('influxdata', 'influxdb', opts)
5452 end
5553 end
5654 end
lib/docs/scrapers/moment.rb+1−2
@@ -24,8 +24,7 @@ module Docs · 23 unmodified lines
2424 HTML
2525
2626 def get_latest_version(opts)
27− doc = fetch_doc('http://momentjs.com/', opts)
28− doc.at_css('.hero-title > h1 > span').content
27+ get_github_tags('moment', 'moment', opts)[0]['name']
2928 end
3029 end
3130 end
lib/docs/scrapers/perl.rb+1−2
@@ -46,8 +46,7 @@ module Docs · 45 unmodified lines
4646
4747 def get_latest_version(opts)
4848 doc = fetch_doc('https://perldoc.perl.org/', opts)
49− header = doc.at_css('h2.h1').content
50− header.scan(/Perl ([0-9.]+)/)[0][0]
49+ doc.at_css('#dropdownlink-stable').content
5150 end
5251 end
5352 end
lib/docs/scrapers/php.rb+2−3
@@ -68,9 +68,8 @@ module Docs · 67 unmodified lines
6868 HTML
6969
7070 def get_latest_version(opts)
71− doc = fetch_doc('https://secure.php.net/manual/en/doc.changelog.php', opts)
72− label = doc.at_css('tbody.gen-changelog > tr > td').content
73− label.split(',').last.strip
71+ doc = fetch_doc('https://www.php.net/supported-versions.php', opts)
72+ doc.at_css('table > tbody > .stable:last-of-type > td > a').content.strip
7473 end
7574 end
7675 end
lib/docs/scrapers/python.rb+1−1
@@ -68,7 +68,7 @@ module Docs · 67 unmodified lines
6868
6969 def get_latest_version(opts)
7070 doc = fetch_doc('https://docs.python.org/', opts)
71− doc.at_css('.version_switcher_placeholder').content
71+ doc.at_css('title').content.split(' ')[0]
7272 end
7373 end
7474 end
lib/docs/scrapers/react_native.rb+2−2
@@ -32,8 +32,8 @@ module Docs · 31 unmodified lines
3232 HTML
3333
3434 def get_latest_version(opts)
35− doc = fetch_doc('https://facebook.github.io/react-native/docs/getting-started.html', opts)
36− doc.at_css('header > a > h3').content
35+ doc = fetch_doc('https://reactnative.dev/docs/getting-started', opts)
36+ doc.at_css('meta[name="docsearch:version"]')['content']
3737 end
3838 end
3939 end
lib/docs/scrapers/scikit_learn.rb+1−2
@@ -26,8 +26,7 @@ module Docs · 25 unmodified lines
2626 HTML
2727
2828 def get_latest_version(opts)
29− doc = fetch_doc('https://scikit-learn.org/stable/documentation.html', opts)
30− doc.at_css('.body h1').content.scan(/([0-9.]+)/)[0][0]
29+ get_latest_github_release('scikit-learn', 'scikit-learn', opts)
3130 end
3231 end
3332 end
lib/docs/scrapers/statsmodels.rb+1−2
@@ -22,8 +22,7 @@ module Docs · 21 unmodified lines
2222 HTML
2323
2424 def get_latest_version(opts)
25− doc = fetch_doc('http://www.statsmodels.org/stable/', opts)
26− doc.at_css('.sphinxsidebarwrapper h3 + p > b').content[1..-1]
25+ get_latest_github_release('statsmodels', 'statsmodels', opts)
2726 end
2827 end
2928 end
lib/docs/scrapers/vagrant.rb+1−2
@@ -20,8 +20,7 @@ module Docs · 19 unmodified lines
2020 HTML
2121
2222 def get_latest_version(opts)
23− contents = get_github_file_contents('hashicorp', 'vagrant', 'website/config.rb', opts)
24− contents.scan(/version\s+=\s+"([0-9.]+)"/)[0][0]
23+ get_github_tags('hashicorp', 'vagrant', opts)[0]['name'][1..-1]
2524 end
2625 end
2726 end