History

Merge pull request #2441 from ClasherKasten/fix/version-checks

Fix multiple version checks of scrapers.

Simon Legner committed 1 year ago

Commit 94a161a2 parents bcf7dc2 31ca6d47 files · +9 −13Browse files

Unified · Split

7 files
  1. lib/docs/scrapers/docker.rb +1 −1
  2. lib/docs/scrapers/meteor.rb +1 −2
  3. lib/docs/scrapers/nix.rb +1 −3
  4. lib/docs/scrapers/phpunit.rb +2 −2
  5. lib/docs/scrapers/redis.rb +1 −2
  6. lib/docs/scrapers/sass.rb +2 −2
  7. lib/docs/scrapers/trio.rb +1 −1
lib/docs/scrapers/docker.rb+1−1
@@ -96,7 +96,7 @@ module Docs · 95 unmodified lines
96 96
97 def get_latest_version(opts)97 def get_latest_version(opts)
98 doc = fetch_doc('https://docs.docker.com/engine/release-notes/', opts)98 doc = fetch_doc('https://docs.docker.com/engine/release-notes/', opts)
99 latest_version = doc.at_css('.DocSearch-content > h2 > a').content.strip99 latest_version = doc.at_css('h2.scroll-mt-20 > a').content.strip
100 latest_version.rpartition(' ')[-1]100 latest_version.rpartition(' ')[-1]
101 end101 end
102 end102 end
lib/docs/scrapers/meteor.rb+1−2
@@ -47,8 +47,7 @@ module Docs · 46 unmodified lines
47 end47 end
48 48
49 def get_latest_version(opts)49 def get_latest_version(opts)
50 doc = fetch_doc('https://docs.meteor.com/#/full/', opts)50 get_npm_version('meteor', opts)
51 doc.at_css('select.version-select > option').content
52 end51 end
53 end52 end
54end53end
lib/docs/scrapers/nix.rb+1−3
@@ -23,9 +23,7 @@ module Docs · 22 unmodified lines
23 23
24 def get_latest_version(opts)24 def get_latest_version(opts)
25 doc = fetch_doc('https://nixos.org/manual/nix/stable/', opts)25 doc = fetch_doc('https://nixos.org/manual/nix/stable/', opts)
26 json = JSON.parse(doc.at_css('body')['data-nix-channels'])26 doc.at_css('a.active')['href'].scan(/([0-9.]+)/)[0][0]
27 channel = json.find { |c| c['channel'] == 'stable' }
28 channel['version']
29 end27 end
30 end28 end
31end29end
lib/docs/scrapers/phpunit.rb+2−2
@@ -77,8 +77,8 @@ module Docs · 76 unmodified lines
77 77
78 def get_latest_version(opts)78 def get_latest_version(opts)
79 doc = fetch_doc('https://phpunit.readthedocs.io/', opts)79 doc = fetch_doc('https://phpunit.readthedocs.io/', opts)
80 label = doc.at_css('.rst-current-version').content.strip80 label = doc.at_css('meta[name="readthedocs-version-slug"]')["content"]
81 label.scan(/v: ([0-9.]+)/)[0][0]81 label
82 end82 end
83 83
84 end84 end
lib/docs/scrapers/redis.rb+1−2
@@ -22,8 +22,7 @@ module Docs · 21 unmodified lines
22 22
23 def get_latest_version(opts)23 def get_latest_version(opts)
24 body = fetch('http://download.redis.io/redis-stable/00-RELEASENOTES', opts)24 body = fetch('http://download.redis.io/redis-stable/00-RELEASENOTES', opts)
25 body = body.lines[1..-1].join25 body.scan(/Redis Community Edition ([0-9.]+)/)[0][0]
26 body.scan(/Redis ([0-9.]+)/)[0][0]
27 end26 end
28 27
29 private28 private
lib/docs/scrapers/sass.rb+2−2
@@ -20,13 +20,13 @@ module Docs · 19 unmodified lines
20 &copy; 2006&ndash;2024 the Sass team, and numerous contributors<br>20 &copy; 2006&ndash;2024 the Sass team, and numerous contributors<br>
21 Licensed under the MIT License.21 Licensed under the MIT License.
22 HTML22 HTML
23
24 private
25 23
26 def get_latest_version(opts)24 def get_latest_version(opts)
27 get_npm_version('sass', opts)25 get_npm_version('sass', opts)
28 end26 end
29 27
28 private
29
30 def parse(response)30 def parse(response)
31 response.body.gsub! '<span class="widont">&nbsp;</span>', '&nbsp;'31 response.body.gsub! '<span class="widont">&nbsp;</span>', '&nbsp;'
32 end32 end
lib/docs/scrapers/trio.rb+1−1
@@ -25,7 +25,7 @@ module Docs · 24 unmodified lines
25 25
26 def get_latest_version(opts)26 def get_latest_version(opts)
27 doc = fetch_doc('https://trio.readthedocs.io/en/stable/', opts)27 doc = fetch_doc('https://trio.readthedocs.io/en/stable/', opts)
28 doc.at_css('.rst-other-versions a[href^="/en/v"]').content[1..-1]28 doc.at_css('div.trio-version').content[0..-1]
29 end29 end
30 end30 end
31end31end