Browse Source

Update Electron/redis/Nix get_latest_version algorithms.

spamguy 1 month ago
parent
commit
ecc4939eb5
3 changed files with 7 additions and 4 deletions
  1. 5 2
      lib/docs/scrapers/electron.rb
  2. 1 1
      lib/docs/scrapers/nix.rb
  3. 1 1
      lib/docs/scrapers/redis.rb

+ 5 - 2
lib/docs/scrapers/electron.rb

@@ -26,8 +26,11 @@ module Docs
     HTML
     HTML
 
 
     def get_latest_version(opts)
     def get_latest_version(opts)
-      doc = fetch_doc('https://www.electronjs.org/releases/stable', opts)
-      doc.at_css('.release-card__metadata>a')['href'].gsub!(/[a-zA-Z\/:]/, '')[1..-1]
+      doc = fetch_doc('https://releases.electronjs.org/release?channel=stable', opts)
+
+      # Builds are sorted by build time, not latest version. Manually sort rows by version.
+      # This list is paginated; it is assumed the latest version is somewhere on the first page.
+      doc.css('table.w-full > tbody > tr td:first-child').map(&:content).sort!.last
     end
     end
   end
   end
 end
 end

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

@@ -23,7 +23,7 @@ module Docs
 
 
     def get_latest_version(opts)
     def get_latest_version(opts)
       doc = fetch_doc('https://nixos.org/manual/nix/stable/', opts)
       doc = fetch_doc('https://nixos.org/manual/nix/stable/', opts)
-      doc.at_css('a.active')['href'].scan(/([0-9.]+)/)[0][0]
+      doc.at_css('h1.menu-title').content.scan(/([0-9.]+)/).first.first
     end
     end
   end
   end
 end
 end

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

@@ -22,7 +22,7 @@ module Docs
 
 
     def get_latest_version(opts)
     def get_latest_version(opts)
       body = fetch('http://download.redis.io/redis-stable/00-RELEASENOTES', opts)
       body = fetch('http://download.redis.io/redis-stable/00-RELEASENOTES', opts)
-      body.scan(/Redis Community Edition ([0-9.]+)/)[0][0]
+      body.scan(/^Redis ([0-9.]+)\s+Released/).first.first
     end
     end
 
 
     private
     private