Skip to content

Commit 6ee1693

Browse files
committed
Implement get_latest_version for the remaining scrapers
1 parent 0315c88 commit 6ee1693

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+335
-2
lines changed

lib/docs/scrapers/nginx.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,12 @@ class Nginx < UrlScraper
2525
&copy; 2011-2018 Nginx, Inc.<br>
2626
Licensed under the BSD License.
2727
HTML
28+
29+
def get_latest_version(options, &block)
30+
fetch_doc('https://nginx.org/en/download.html', options) do |doc|
31+
table = doc.at_css('#content > table').inner_html
32+
block.call table.scan(/nginx-([0-9.]+)</)[0][0]
33+
end
34+
end
2835
end
2936
end

lib/docs/scrapers/nginx_lua_module.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ class NginxLuaModule < Github
44
self.slug = 'nginx_lua_module'
55
self.release = '0.10.13'
66
self.base_url = "https://github.com/openresty/lua-nginx-module/tree/v#{self.release}/"
7+
self.links = {
8+
code: 'https://github.com/openresty/lua-nginx-module'
9+
}
710

811
html_filters.push 'nginx_lua_module/clean_html', 'nginx_lua_module/entries', 'title'
912

@@ -15,5 +18,12 @@ class NginxLuaModule < Github
1518
&copy; 2009&ndash;2018 Yichun "agentzh" Zhang (章亦春), OpenResty Inc.<br>
1619
Licensed under the BSD License.
1720
HTML
21+
22+
def get_latest_version(options, &block)
23+
get_github_tags('openresty', 'lua-nginx-module', options) do |tags|
24+
tag = tags.find { |tag| !tag['name'].include?('rc') }
25+
block.call tag['name'][1..-1]
26+
end
27+
end
1828
end
1929
end

lib/docs/scrapers/nim.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,11 @@ class Nim < UrlScraper
1717
&copy; 2006&ndash;2018 Andreas Rumpf<br>
1818
Licensed under the MIT License.
1919
HTML
20+
21+
def get_latest_version(options, &block)
22+
fetch_doc('https://nim-lang.org/docs/overview.html', options) do |doc|
23+
block.call doc.at_css('.container > .docinfo > tbody > tr:last-child > td').content.strip
24+
end
25+
end
2026
end
2127
end

lib/docs/scrapers/node.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,11 @@ class Node < UrlScraper
4646
self.release = '4.9.1'
4747
self.base_url = 'https://nodejs.org/dist/latest-v4.x/docs/api/'
4848
end
49+
50+
def get_latest_version(options, &block)
51+
fetch_doc('https://nodejs.org/en/', options) do |doc|
52+
block.call doc.at_css('#home-intro > .home-downloadblock:last-of-type > a')['data-version'][1..-1]
53+
end
54+
end
4955
end
5056
end

lib/docs/scrapers/nokogiri2.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,11 @@ class Nokogiri2 < Rdoc
1919
Patrick Mahoney, Yoko Harada, Akinori Musha, John Shahid, Lars Kanis<br>
2020
Licensed under the MIT License.
2121
HTML
22+
23+
def get_latest_version(options, &block)
24+
get_latest_github_release('sparklemotion', 'nokogiri', options) do |release|
25+
block.call release['tag_name'][1..-1]
26+
end
27+
end
2228
end
2329
end

lib/docs/scrapers/npm.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,11 @@ class Npm < UrlScraper
2929
Licensed under the npm License.<br>
3030
npm is a trademark of npm, Inc.
3131
HTML
32+
33+
def get_latest_version(options, &block)
34+
get_latest_github_release('npm', 'cli', options) do |release|
35+
block.call release['tag_name'][1..-1]
36+
end
37+
end
3238
end
3339
end

lib/docs/scrapers/numpy.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,11 @@ class Numpy < FileScraper
4949
self.release = '1.10.4'
5050
self.base_url = "https://docs.scipy.org/doc/numpy-#{self.release}/reference/"
5151
end
52+
53+
def get_latest_version(options, &block)
54+
get_latest_github_release('numpy', 'numpy', options) do |release|
55+
block.call release['tag_name'][1..-1]
56+
end
57+
end
5258
end
5359
end

lib/docs/scrapers/openjdk.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,26 @@ class Openjdk < FileScraper
8686
def read_file(path)
8787
File.read(path).force_encoding('iso-8859-1').encode('utf-8') rescue nil
8888
end
89+
90+
def get_latest_version(options, &block)
91+
latest_version = 8
92+
current_attempt = latest_version
93+
attempts = 0
94+
95+
while attempts < 3
96+
current_attempt += 1
97+
98+
fetch_doc("https://packages.debian.org/sid/openjdk-#{current_attempt}-doc", options) do |doc|
99+
if doc.at_css('.perror').nil?
100+
latest_version = current_attempt
101+
attempts = 0
102+
else
103+
attempts += 1
104+
end
105+
end
106+
end
107+
108+
block.call latest_version.to_s
109+
end
89110
end
90111
end

lib/docs/scrapers/opentsdb.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,11 @@ class Opentsdb < UrlScraper
1818
&copy; 2010&ndash;2016 The OpenTSDB Authors<br>
1919
Licensed under the GNU LGPLv2.1+ and GPLv3+ licenses.
2020
HTML
21+
22+
def get_latest_version(options, &block)
23+
get_latest_github_release('OpenTSDB', 'opentsdb', options) do |release|
24+
block.call release['tag_name'][1..-1]
25+
end
26+
end
2127
end
2228
end

lib/docs/scrapers/padrino.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,11 @@ class Padrino < UrlScraper
2323
stub 'index2' do
2424
request_one(url_for('index')).body
2525
end
26+
27+
def get_latest_version(options, &block)
28+
get_github_tags('padrino', 'padrino-framework', options) do |tags|
29+
block.call tags[0]['name']
30+
end
31+
end
2632
end
2733
end

0 commit comments

Comments
 (0)