Refactoring and cleaning up

pull/986/head
Jasper van Merle 6 years ago
parent cd43632a2c
commit 41e0a138a6

@ -187,39 +187,41 @@ More information about how filters work is available on the [Filter Reference](.
## Keeping scrapers up-to-date ## Keeping scrapers up-to-date
In order to keep scrapers up-to-date the `get_latest_version(options, &block)` method should be overridden. If `self.release` is defined, this should return the latest version of the documentation. If `self.release` is not defined, it should return the Epoch time when the documentation was last modified. If the documentation will never change, simply return `1.0.0`. The result of this method is periodically reported in a "Documentation versions report" issue which helps maintainers keep track of outdated documentations. In order to keep scrapers up-to-date the `get_latest_version(opts)` method should be overridden. If `self.release` is defined, this should return the latest version of the documentation. If `self.release` is not defined, it should return the Epoch time when the documentation was last modified. If the documentation will never change, simply return `1.0.0`. The result of this method is periodically reported in a "Documentation versions report" issue which helps maintainers keep track of outdated documentations.
To make life easier, there are a few utility methods that you can use in `get_latest_version`: To make life easier, there are a few utility methods that you can use in `get_latest_version`:
* `fetch(url, options, &block)` * `fetch(url, opts)`
Makes a GET request to the url and calls `&block` with the body. Makes a GET request to the url and returns the response body.
Example: [lib/docs/scrapers/bash.rb](../lib/docs/scrapers/bash.rb) Example: [lib/docs/scrapers/bash.rb](../lib/docs/scrapers/bash.rb)
* `fetch_doc(url, options, &block)` * `fetch_doc(url, opts)`
Makes a GET request to the url and calls `&block` with the HTML body converted to a Nokogiri document. Makes a GET request to the url and returns the HTML body converted to a Nokogiri document.
Example: [lib/docs/scrapers/git.rb](../lib/docs/scrapers/git.rb) Example: [lib/docs/scrapers/git.rb](../lib/docs/scrapers/git.rb)
* `fetch_json(url, options, &block)` * `fetch_json(url, opts)`
Makes a GET request to the url and calls `&block` with the JSON body converted to a dictionary. Makes a GET request to the url and returns the JSON body converted to a dictionary.
* `get_npm_version(package, options, &block)`
Calls `&block` with the latest version of the given npm package. Example: [lib/docs/scrapers/mdn/mdn.rb](../lib/docs/scrapers/mdn/mdn.rb)
* `get_npm_version(package, opts)`
Returns the latest version of the given npm package.
Example: [lib/docs/scrapers/bower.rb](../lib/docs/scrapers/bower.rb) Example: [lib/docs/scrapers/bower.rb](../lib/docs/scrapers/bower.rb)
* `get_latest_github_release(owner, repo, options, &block)` * `get_latest_github_release(owner, repo, opts)`
Calls `&block` with the latest GitHub release of the given repository ([format](https://developer.github.com/v3/repos/releases/#get-the-latest-release)). Returns the latest GitHub release of the given repository ([format](https://developer.github.com/v3/repos/releases/#get-the-latest-release)).
Example: [lib/docs/scrapers/jsdoc.rb](../lib/docs/scrapers/jsdoc.rb) Example: [lib/docs/scrapers/jsdoc.rb](../lib/docs/scrapers/jsdoc.rb)
* `get_github_tags(owner, repo, options, &block)` * `get_github_tags(owner, repo, opts)`
Calls `&block` with the list of tags on the given repository ([format](https://developer.github.com/v3/repos/#list-tags)). Returns the list of tags on the given repository ([format](https://developer.github.com/v3/repos/#list-tags)).
Example: [lib/docs/scrapers/liquid.rb](../lib/docs/scrapers/liquid.rb) Example: [lib/docs/scrapers/liquid.rb](../lib/docs/scrapers/liquid.rb)
* `get_github_file_contents(owner, repo, path, options, &block)` * `get_github_file_contents(owner, repo, path, opts)`
Calls `&block` with the contents of the requested file in the default branch of the given repository. Returns the contents of the requested file in the default branch of the given repository.
Example: [lib/docs/scrapers/minitest.rb](../lib/docs/scrapers/minitest.rb) Example: [lib/docs/scrapers/minitest.rb](../lib/docs/scrapers/minitest.rb)

@ -164,16 +164,15 @@ module Docs
raise NotImplementedError raise NotImplementedError
end end
def get_scraper_version(opts, &block) def get_scraper_version(opts)
if self.class.method_defined?(:options) and !options[:release].nil? if self.class.method_defined?(:options) and !options[:release].nil?
block.call options[:release] options[:release]
else else
# If options[:release] does not exist, we return the Epoch timestamp of when the doc was last modified in DevDocs production # If options[:release] does not exist, we return the Epoch timestamp of when the doc was last modified in DevDocs production
fetch_json('https://devdocs.io/docs.json', opts) do |json| json = fetch_json('https://devdocs.io/docs.json', opts)
items = json.select {|item| item['name'] == self.class.name} items = json.select {|item| item['name'] == self.class.name}
items = items.map {|item| item['mtime']} items = items.map {|item| item['mtime']}
block.call items.max items.max
end
end end
end end
@ -181,7 +180,7 @@ module Docs
# If options[:release] is defined, it should be in the same format # If options[:release] is defined, it should be in the same format
# If options[:release] is not defined, it should return the Epoch timestamp of when the documentation was last updated # If options[:release] is not defined, it should return the Epoch timestamp of when the documentation was last updated
# If the docs will never change, simply return '1.0.0' # If the docs will never change, simply return '1.0.0'
def get_latest_version(options, &block) def get_latest_version(opts)
raise NotImplementedError raise NotImplementedError
end end
@ -216,55 +215,49 @@ module Docs
# Utility methods for get_latest_version # Utility methods for get_latest_version
# #
def fetch(url, options, &block) def fetch(url, opts)
headers = {} headers = {}
if options.key?(:github_token) and url.start_with?('https://api.github.com/') if opts.key?(:github_token) and url.start_with?('https://api.github.com/')
headers['Authorization'] = "token #{options[:github_token]}" headers['Authorization'] = "token #{opts[:github_token]}"
end end
options[:logger].debug("Fetching #{url}") opts[:logger].debug("Fetching #{url}")
response = Request.run(url, { headers: headers })
Request.run(url, { headers: headers }) do |response| if response.success?
if response.success? response.body
block.call response.body else
else opts[:logger].error("Couldn't fetch #{url} (response code #{response.code})")
options[:logger].error("Couldn't fetch #{url} (response code #{response.code})") nil
block.call nil
end
end end
end end
def fetch_doc(url, options, &block) def fetch_doc(url, opts)
fetch(url, options) do |body| body = fetch(url, opts)
block.call Nokogiri::HTML.parse(body, nil, 'UTF-8') Nokogiri::HTML.parse(body, nil, 'UTF-8')
end
end end
def fetch_json(url, options, &block) def fetch_json(url, opts)
fetch(url, options) do |body| JSON.parse fetch(url, opts)
block.call JSON.parse(body)
end
end end
def get_npm_version(package, options, &block) def get_npm_version(package, opts)
fetch_json("https://registry.npmjs.com/#{package}", options) do |json| json = fetch_json("https://registry.npmjs.com/#{package}", opts)
block.call json['dist-tags']['latest'] json['dist-tags']['latest']
end
end end
def get_latest_github_release(owner, repo, options, &block) def get_latest_github_release(owner, repo, opts)
fetch_json("https://api.github.com/repos/#{owner}/#{repo}/releases/latest", options, &block) fetch_json("https://api.github.com/repos/#{owner}/#{repo}/releases/latest", opts)
end end
def get_github_tags(owner, repo, options, &block) def get_github_tags(owner, repo, opts)
fetch_json("https://api.github.com/repos/#{owner}/#{repo}/tags", options, &block) fetch_json("https://api.github.com/repos/#{owner}/#{repo}/tags", opts)
end end
def get_github_file_contents(owner, repo, path, options, &block) def get_github_file_contents(owner, repo, path, opts)
fetch_json("https://api.github.com/repos/#{owner}/#{repo}/contents/#{path}", options) do |json| json = fetch_json("https://api.github.com/repos/#{owner}/#{repo}/contents/#{path}", opts)
block.call(Base64.decode64(json['content'])) Base64.decode64(json['content'])
end
end end
end end
end end

@ -155,8 +155,8 @@ module Docs
end end
end end
def get_latest_version(options, &block) def get_latest_version(opts)
get_npm_version('@angular/core', options, &block) get_npm_version('@angular/core', opts)
end end
private private

@ -70,8 +70,8 @@ module Docs
self.base_url = "https://code.angularjs.org/#{release}/docs/partials/" self.base_url = "https://code.angularjs.org/#{release}/docs/partials/"
end end
def get_latest_version(options, &block) def get_latest_version(opts)
get_npm_version('angular', options, &block) get_npm_version('angular', opts)
end end
end end
end end

@ -88,10 +88,9 @@ module Docs
list_of_all_modules.html) list_of_all_modules.html)
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://docs.ansible.com/ansible/latest/index.html', options) do |doc| doc = fetch_doc('https://docs.ansible.com/ansible/latest/index.html', opts)
block.call doc.at_css('.DocSiteProduct-CurrentVersion').content.strip doc.at_css('.DocSiteProduct-CurrentVersion').content.strip
end
end end
end end
end end

@ -34,10 +34,9 @@ module Docs
Licensed under the Apache License, Version 2.0. Licensed under the Apache License, Version 2.0.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('http://httpd.apache.org/docs/', options) do |doc| doc = fetch_doc('http://httpd.apache.org/docs/', opts)
block.call doc.at_css('#apcontents > ul a')['href'][0...-1] doc.at_css('#apcontents > ul a')['href'][0...-1]
end
end end
end end
end end

@ -43,11 +43,10 @@ module Docs
self.base_url = "https://pig.apache.org/docs/r#{release}/" self.base_url = "https://pig.apache.org/docs/r#{release}/"
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://pig.apache.org/', options) do |doc| doc = fetch_doc('https://pig.apache.org/', opts)
item = doc.at_css('div[id="menu_1.2"] > .menuitem:last-child') item = doc.at_css('div[id="menu_1.2"] > .menuitem:last-child')
block.call item.content.strip.sub(/Release /, '') item.content.strip.sub(/Release /, '')
end
end end
end end
end end

@ -18,11 +18,9 @@ module Docs
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://caolan.github.io/async/', options) do |doc| doc = fetch_doc('https://caolan.github.io/async/', opts)
version = doc.at_css('#version-dropdown > a').content.strip[1..-1] doc.at_css('#version-dropdown > a').content.strip[1..-1]
block.call version
end
end end
end end
end end

@ -23,10 +23,9 @@ module Docs
'<div></div>' '<div></div>'
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://babeljs.io/docs/en/', options) do |doc| doc = fetch_doc('https://babeljs.io/docs/en/', opts)
block.call doc.at_css('a[href="/versions"] > h3').content doc.at_css('a[href="/versions"] > h3').content
end
end end
end end
end end

@ -21,11 +21,9 @@ module Docs
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://backbonejs.org/', options) do |doc| doc = fetch_doc('https://backbonejs.org/', opts)
version = doc.at_css('.version').content doc.at_css('.version').content[1...-1]
block.call version[1...-1]
end
end end
end end
end end

@ -18,11 +18,9 @@ module Docs
Licensed under the GNU Free Documentation License. Licensed under the GNU Free Documentation License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
fetch('https://www.gnu.org/software/bash/manual/html_node/index.html', options) do |body| body = fetch('https://www.gnu.org/software/bash/manual/html_node/index.html', opts)
version = body.scan(/, Version ([0-9.]+)/)[0][0] body.scan(/, Version ([0-9.]+)/)[0][0][0...-1]
block.call version[0...-1]
end
end end
end end
end end

@ -19,8 +19,8 @@ module Docs
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
get_npm_version('bluebird', options, &block) get_npm_version('bluebird', opts)
end end
end end
end end

@ -35,10 +35,9 @@ module Docs
options[:only] = %w(getting-started/ css/ components/ javascript/) options[:only] = %w(getting-started/ css/ components/ javascript/)
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://getbootstrap.com/', options) do |doc| doc = fetch_doc('https://getbootstrap.com/', opts)
block.call doc.at_css('#bd-versions').content.strip[1..-1] doc.at_css('#bd-versions').content.strip[1..-1]
end
end end
end end
end end

@ -28,11 +28,10 @@ module Docs
self.base_url = "https://bottlepy.org/docs/#{self.version}/" self.base_url = "https://bottlepy.org/docs/#{self.version}/"
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://bottlepy.org/docs/stable/', options) do |doc| doc = fetch_doc('https://bottlepy.org/docs/stable/', opts)
label = doc.at_css('.sphinxsidebarwrapper > ul > li > b') label = doc.at_css('.sphinxsidebarwrapper > ul > li > b')
block.call label.content.sub(/Bottle /, '') label.content.sub(/Bottle /, '')
end
end end
end end
end end

@ -20,8 +20,8 @@ module Docs
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
get_npm_version('bower', options, &block) get_npm_version('bower', opts)
end end
end end
end end

@ -26,12 +26,11 @@ module Docs
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0. Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://en.cppreference.com/w/Cppreference:Archives', options) do |doc| doc = fetch_doc('https://en.cppreference.com/w/Cppreference:Archives', opts)
link = doc.at_css('a[title^="File:"]') link = doc.at_css('a[title^="File:"]')
date = link.content.scan(/(\d+)\./)[0][0] date = link.content.scan(/(\d+)\./)[0][0]
block.call DateTime.strptime(date, '%Y%m%d').to_time.to_i DateTime.strptime(date, '%Y%m%d').to_time.to_i
end
end end
private private

@ -71,10 +71,9 @@ module Docs
self.base_url = 'https://api.cakephp.org/2.7/' self.base_url = 'https://api.cakephp.org/2.7/'
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://api.cakephp.org/3.7/', options) do |doc| doc = fetch_doc('https://api.cakephp.org/3.7/', opts)
block.call doc.at_css('.version-picker .dropdown-toggle').content.strip doc.at_css('.version-picker .dropdown-toggle').content.strip
end
end end
private private

@ -24,8 +24,8 @@ module Docs
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
get_npm_version('chai', options, &block) get_npm_version('chai', opts)
end end
end end
end end

@ -48,10 +48,9 @@ module Docs
options[:only_patterns] = [/\A#{client_path}\//, /\A#{server_path}\//] options[:only_patterns] = [/\A#{client_path}\//, /\A#{server_path}\//]
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://downloads.chef.io/chef', options) do |doc| doc = fetch_doc('https://downloads.chef.io/chef', opts)
block.call doc.at_css('h1.product-heading > span').content.strip doc.at_css('h1.product-heading > span').content.strip
end
end end
end end
end end

@ -28,10 +28,9 @@ module Docs
self.base_url = 'https://clojure.github.io/clojure/branch-clojure-1.7.0/' self.base_url = 'https://clojure.github.io/clojure/branch-clojure-1.7.0/'
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('http://clojure.github.io/clojure/index.html', options) do |doc| doc = fetch_doc('http://clojure.github.io/clojure/index.html', opts)
block.call doc.at_css('#header-version').content[1..-1] doc.at_css('#header-version').content[1..-1]
end
end end
end end
end end

@ -60,11 +60,10 @@ module Docs
self.base_url = 'https://cmake.org/cmake/help/v3.5/' self.base_url = 'https://cmake.org/cmake/help/v3.5/'
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://cmake.org/documentation/', options) do |doc| doc = fetch_doc('https://cmake.org/documentation/', opts)
link = doc.at_css('.entry-content ul > li > strong > a > big') link = doc.at_css('.entry-content ul > li > strong > a > big')
block.call link.content.scan(/([0-9.]+)/)[0][0] link.content.scan(/([0-9.]+)/)[0][0]
end
end end
end end
end end

@ -19,10 +19,9 @@ module Docs
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://codeception.com/changelog', options) do |doc| doc = fetch_doc('https://codeception.com/changelog', opts)
block.call doc.at_css('#page > h4').content doc.at_css('#page > h4').content
end
end end
end end
end end

@ -22,8 +22,8 @@ module Docs
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
get_npm_version('codeceptjs', options, &block) get_npm_version('codeceptjs', opts)
end end
end end
end end

@ -39,11 +39,10 @@ module Docs
self.release = '3.1.8' self.release = '3.1.8'
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://codeigniter.com/user_guide/changelog.html', options) do |doc| doc = fetch_doc('https://codeigniter.com/user_guide/changelog.html', opts)
header = doc.at_css('#change-log h2') header = doc.at_css('#change-log h2')
block.call header.content.scan(/([0-9.]+)/)[0][0] header.content.scan(/([0-9.]+)/)[0][0]
end
end end
end end
end end

@ -31,8 +31,8 @@ module Docs
options[:container] = '.container' options[:container] = '.container'
end end
def get_latest_version(options, &block) def get_latest_version(opts)
get_npm_version('coffeescript', options, &block) get_npm_version('coffeescript', opts)
end end
end end
end end

@ -43,13 +43,14 @@ module Docs
self.base_url = 'https://cordova.apache.org/docs/en/6.x/' self.base_url = 'https://cordova.apache.org/docs/en/6.x/'
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://cordova.apache.org/docs/en/latest/', options) do |doc| doc = fetch_doc('https://cordova.apache.org/docs/en/latest/', opts)
label = doc.at_css('#versionDropdown').content.strip
version = label.scan(/([0-9.]+)/)[0][0] label = doc.at_css('#versionDropdown').content.strip
version = version[0...-1] if version.end_with?('.') version = label.scan(/([0-9.]+)/)[0][0]
block.call version version = version[0...-1] if version.end_with?('.')
end
version
end end
end end
end end

@ -35,12 +35,11 @@ module Docs
HTML HTML
# Same as get_latest_version in lib/docs/scrapers/c.rb # Same as get_latest_version in lib/docs/scrapers/c.rb
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://en.cppreference.com/w/Cppreference:Archives', options) do |doc| doc = fetch_doc('https://en.cppreference.com/w/Cppreference:Archives', opts)
link = doc.at_css('a[title^="File:"]') link = doc.at_css('a[title^="File:"]')
date = link.content.scan(/(\d+)\./)[0][0] date = link.content.scan(/(\d+)\./)[0][0]
block.call DateTime.strptime(date, '%Y%m%d').to_time.to_i DateTime.strptime(date, '%Y%m%d').to_time.to_i
end
end end
private private

@ -35,10 +35,9 @@ module Docs
end end
} }
def get_latest_version(options, &block) def get_latest_version(opts)
fetch('https://crystal-lang.org/api', options) do |body| body = fetch('https://crystal-lang.org/api', opts)
block.call body.scan(/Crystal Docs ([0-9.]+)/)[0][0] body.scan(/Crystal Docs ([0-9.]+)/)[0][0]
end
end end
end end
end end

@ -27,10 +27,9 @@ module Docs
%w(https://dlang.org/phobos/index.html https://dlang.org/spec/intro.html) %w(https://dlang.org/phobos/index.html https://dlang.org/spec/intro.html)
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://dlang.org/changelog/', options) do |doc| doc = fetch_doc('https://dlang.org/changelog/', opts)
block.call doc.at_css('#content > ul > li:nth-child(2) > a')['id'] doc.at_css('#content > ul > li:nth-child(2) > a')['id']
end
end end
end end
end end

@ -59,8 +59,8 @@ module Docs
options[:only_patterns] = [/\.md\z/] options[:only_patterns] = [/\.md\z/]
end end
def get_latest_version(options, &block) def get_latest_version(opts)
get_npm_version('d3', options, &block) get_npm_version('d3', opts)
end end
end end
end end

@ -32,11 +32,10 @@ module Docs
self.base_url = "https://api.dartlang.org/stable/#{release}/" self.base_url = "https://api.dartlang.org/stable/#{release}/"
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://api.dartlang.org/', options) do |doc| doc = fetch_doc('https://api.dartlang.org/', opts)
label = doc.at_css('footer > span').content.strip label = doc.at_css('footer > span').content.strip
block.call label.sub(/Dart /, '') label.sub(/Dart /, '')
end
end end
end end
end end

@ -64,10 +64,9 @@ module Docs
self.base_url = 'https://docs.djangoproject.com/en/1.8/' self.base_url = 'https://docs.djangoproject.com/en/1.8/'
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://docs.djangoproject.com/', options) do |doc| doc = fetch_doc('https://docs.djangoproject.com/', opts)
block.call doc.at_css('#doc-versions > li.current > span > strong').content doc.at_css('#doc-versions > li.current > span > strong').content
end
end end
end end
end end

@ -138,11 +138,10 @@ module Docs
options[:only_patterns] << /\Aswarm\// options[:only_patterns] << /\Aswarm\//
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://docs.docker.com/', options) do |doc| doc = fetch_doc('https://docs.docker.com/', opts)
label = doc.at_css('.nav-container button.dropdown-toggle').content.strip label = doc.at_css('.nav-container button.dropdown-toggle').content.strip
block.call label.scan(/([0-9.]+)/)[0][0] label.scan(/([0-9.]+)/)[0][0]
end
end end
end end
end end

@ -36,10 +36,9 @@ module Docs
urls.map { |url| "<a href='#{url}'>#{url}</a>" }.join urls.map { |url| "<a href='#{url}'>#{url}</a>" }.join
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://dojotoolkit.org/api/', options) do |doc| doc = fetch_doc('https://dojotoolkit.org/api/', opts)
block.call doc.at_css('#versionSelector > option[selected]').content doc.at_css('#versionSelector > option[selected]').content
end
end end
private private

@ -99,13 +99,14 @@ module Docs
] ]
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('http://cgit.drupalcode.org/drupal', options) do |doc| doc = fetch_doc('http://cgit.drupalcode.org/drupal', opts)
version = doc.at_css('td.form > form > select > option[selected]').content
version = version.scan(/([0-9.]+)/)[0][0] version = doc.at_css('td.form > form > select > option[selected]').content
version = version[0...-1] if version.end_with?('.') version = version.scan(/([0-9.]+)/)[0][0]
block.call version version = version[0...-1] if version.end_with?('.')
end
version
end end
end end
end end

@ -23,10 +23,9 @@ module Docs
Licensed under the MIT license. Licensed under the MIT license.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://electronjs.org/docs', options) do |doc| doc = fetch_doc('https://electronjs.org/docs', opts)
block.call doc.at_css('.docs-version').content doc.at_css('.docs-version').content
end
end end
end end
end end

@ -98,10 +98,9 @@ module Docs
] ]
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://hexdocs.pm/elixir/api-reference.html', options) do |doc| doc = fetch_doc('https://hexdocs.pm/elixir/api-reference.html', opts)
block.call doc.at_css('h2.sidebar-projectVersion').content.strip[1..-1] doc.at_css('h2.sidebar-projectVersion').content.strip[1..-1]
end
end end
end end
end end

@ -57,10 +57,9 @@ module Docs
) )
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://emberjs.com/api/ember/release', options) do |doc| doc = fetch_doc('https://emberjs.com/api/ember/release', opts)
block.call doc.at_css('.sidebar > .select-container .ember-power-select-selected-item').content.strip doc.at_css('.sidebar > .select-container .ember-power-select-selected-item').content.strip
end
end end
end end
end end

@ -56,10 +56,9 @@ module Docs
self.release = '18.3' self.release = '18.3'
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://www.erlang.org/downloads', options) do |doc| doc = fetch_doc('https://www.erlang.org/downloads', opts)
block.call doc.at_css('.col-lg-3 > ul > li').content.strip.sub(/OTP /, '') doc.at_css('.col-lg-3 > ul > li').content.strip.sub(/OTP /, '')
end
end end
end end
end end

@ -21,8 +21,8 @@ module Docs
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
get_npm_version('eslint', options, &block) get_npm_version('eslint', opts)
end end
end end
end end

@ -29,8 +29,8 @@ module Docs
Licensed under the Creative Commons Attribution-ShareAlike License v3.0. Licensed under the Creative Commons Attribution-ShareAlike License v3.0.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
get_npm_version('express', options, &block) get_npm_version('express', opts)
end end
end end
end end

@ -34,10 +34,9 @@ module Docs
self.base_url = "https://falcon.readthedocs.io/en/#{self.release}/" self.base_url = "https://falcon.readthedocs.io/en/#{self.release}/"
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://falcon.readthedocs.io/en/stable/changes/index.html', options) do |doc| doc = fetch_doc('https://falcon.readthedocs.io/en/stable/changes/index.html', opts)
block.call doc.at_css('#changelogs ul > li > a').content doc.at_css('#changelogs ul > li > a').content
end
end end
end end
end end

@ -47,10 +47,9 @@ module Docs
self.base_url = "https://fishshell.com/docs/#{version}/" self.base_url = "https://fishshell.com/docs/#{version}/"
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('http://fishshell.com/docs/current/index.html', options) do |doc| doc = fetch_doc('http://fishshell.com/docs/current/index.html', opts)
block.call doc.at_css('#toc-index').content.scan(/([0-9.]+)/)[0][0] doc.at_css('#toc-index').content.scan(/([0-9.]+)/)[0][0]
end
end end
end end
end end

@ -19,8 +19,8 @@ module Docs
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
get_npm_version('flow-bin', options, &block) get_npm_version('flow-bin', opts)
end end
end end
end end

@ -20,10 +20,9 @@ module Docs
Licensed under the GNU General Public License version 2. Licensed under the GNU General Public License version 2.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://git-scm.com/', options) do |doc| doc = fetch_doc('https://git-scm.com/', opts)
block.call doc.at_css('.version').content.strip doc.at_css('.version').content.strip
end
end end
end end
end end

@ -100,11 +100,10 @@ module Docs
options[:replace_paths] = CPP_PATHS options[:replace_paths] = CPP_PATHS
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://gcc.gnu.org/onlinedocs/', options) do |doc| doc = fetch_doc('https://gcc.gnu.org/onlinedocs/', opts)
label = doc.at_css('ul > li > ul > li > a').content.strip label = doc.at_css('ul > li > ul > li > a').content.strip
block.call label.scan(/([0-9.]+)/)[0][0] label.scan(/([0-9.]+)/)[0][0]
end
end end
end end
end end

@ -26,11 +26,10 @@ module Docs
self.base_url = "https://gcc.gnu.org/onlinedocs/gcc-#{release}/gfortran/" self.base_url = "https://gcc.gnu.org/onlinedocs/gcc-#{release}/gfortran/"
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://gcc.gnu.org/onlinedocs/', options) do |doc| doc = fetch_doc('https://gcc.gnu.org/onlinedocs/', opts)
label = doc.at_css('ul > li > ul > li > a').content.strip label = doc.at_css('ul > li > ul > li > a').content.strip
block.call label.scan(/([0-9.]+)/)[0][0] label.scan(/([0-9.]+)/)[0][0]
end
end end
end end
end end

@ -24,13 +24,14 @@ module Docs
Licensed under the Creative Commons Attribution License 3.0. Licensed under the Creative Commons Attribution License 3.0.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://golang.org/pkg/', options) do |doc| doc = fetch_doc('https://golang.org/pkg/', opts)
footer = doc.at_css('#footer').content
version = footer.scan(/go([0-9.]+)/)[0][0] footer = doc.at_css('#footer').content
version = version[0...-1] if version.end_with?('.') version = footer.scan(/go([0-9.]+)/)[0][0]
block.call version version = version[0...-1] if version.end_with?('.')
end
version
end end
private private

@ -38,10 +38,9 @@ module Docs
self.base_url = "http://docs.godotengine.org/en/#{self.version}/" self.base_url = "http://docs.godotengine.org/en/#{self.version}/"
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://docs.godotengine.org/', options) do |doc| doc = fetch_doc('https://docs.godotengine.org/', opts)
block.call doc.at_css('.version').content.strip doc.at_css('.version').content.strip
end
end end
end end
end end

@ -18,10 +18,9 @@ module Docs
Licensed under the Apache License, Version 2.0. Licensed under the Apache License, Version 2.0.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://graphite.readthedocs.io/en/latest/releases.html', options) do |doc| doc = fetch_doc('https://graphite.readthedocs.io/en/latest/releases.html', opts)
block.call doc.at_css('#release-notes li > a').content doc.at_css('#release-notes li > a').content
end
end end
end end
end end

@ -27,8 +27,8 @@ module Docs
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
get_npm_version('grunt-cli', options, &block) get_npm_version('grunt-cli', opts)
end end
end end
end end

@ -20,8 +20,8 @@ module Docs
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
get_npm_version('handlebars', options, &block) get_npm_version('handlebars', opts)
end end
end end
end end

@ -69,12 +69,11 @@ module Docs
options[:only_patterns] = [/\Alibraries\//] options[:only_patterns] = [/\Alibraries\//]
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://downloads.haskell.org/~ghc/latest/docs/html/', options) do |doc| doc = fetch_doc('https://downloads.haskell.org/~ghc/latest/docs/html/', opts)
links = doc.css('a').to_a links = doc.css('a').to_a
versions = links.map {|link| link['href'].scan(/ghc-([0-9.]+)/)} versions = links.map {|link| link['href'].scan(/ghc-([0-9.]+)/)}
block.call versions.find {|version| !version.empty?}[0][0] versions.find {|version| !version.empty?}[0][0]
end
end end
end end
end end

@ -67,11 +67,10 @@ module Docs
self.base_url = 'https://api.haxe.org/python/' self.base_url = 'https://api.haxe.org/python/'
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://api.haxe.org/', options) do |doc| doc = fetch_doc('https://api.haxe.org/', opts)
label = doc.at_css('.container.main-content h1 > small').content label = doc.at_css('.container.main-content h1 > small').content
block.call label.sub(/version /, '') label.sub(/version /, '')
end
end end
end end
end end

@ -20,10 +20,8 @@ module Docs
Licensed under the BSD 2-Clause License. Licensed under the BSD 2-Clause License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
get_latest_github_release('Homebrew', 'brew', options) do |release| get_latest_github_release('Homebrew', 'brew', opts)['name']
block.call release['name']
end
end end
end end
end end

@ -55,8 +55,8 @@ module Docs
capybara.html capybara.html
end end
def get_latest_version(options, &block) def get_latest_version(opts)
get_npm_version('immutable', options, &block) get_npm_version('immutable', opts)
end end
end end
end end

@ -47,11 +47,10 @@ module Docs
Licensed under the MIT license. Licensed under the MIT license.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://docs.influxdata.com/influxdb/', options) do |doc| doc = fetch_doc('https://docs.influxdata.com/influxdb/', opts)
label = doc.at_css('.navbar--current-product').content.strip label = doc.at_css('.navbar--current-product').content.strip
block.call label.scan(/([0-9.]+)/)[0][0] label.scan(/([0-9.]+)/)[0][0]
end
end end
end end
end end

@ -18,10 +18,8 @@ module Docs
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
get_latest_github_release('jasmine', 'jasmine', options) do |release| get_latest_github_release('jasmine', 'jasmine', opts)['name']
block.call release['name']
end
end end
end end
end end

@ -29,10 +29,9 @@ module Docs
Licensed under the MIT license. Licensed under the MIT license.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://jekyllrb.com/docs/', options) do |doc| doc = fetch_doc('https://jekyllrb.com/docs/', opts)
block.call doc.at_css('.meta a').content[1..-1] doc.at_css('.meta a').content[1..-1]
end
end end
end end
end end

@ -18,10 +18,9 @@ module Docs
Licensed under the BSD License. Licensed under the BSD License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://jestjs.io/docs/en/getting-started', options) do |doc| doc = fetch_doc('https://jestjs.io/docs/en/getting-started', opts)
block.call doc.at_css('header > a > h3').content doc.at_css('header > a > h3').content
end
end end
end end
end end

@ -23,8 +23,8 @@ module Docs
/index/i /index/i
] ]
def get_latest_version(options, &block) def get_latest_version(opts)
get_npm_version('jquery', options, &block) get_npm_version('jquery', opts)
end end
end end
end end

@ -17,11 +17,9 @@ module Docs
url.sub! 'http://api.jquerymobile.com/', 'https://api.jquerymobile.com/' url.sub! 'http://api.jquerymobile.com/', 'https://api.jquerymobile.com/'
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://jquerymobile.com/', options) do |doc| doc = fetch_doc('https://jquerymobile.com/', opts)
label = doc.at_css('.download-box > .download-option:last-child > span').content doc.at_css('.download-box > .download-option:last-child > span').content.sub(/Version /, '')
block.call label.sub(/Version /, '')
end
end end
end end
end end

@ -16,8 +16,8 @@ module Docs
url.sub! 'http://api.jqueryui.com/', 'https://api.jqueryui.com/' url.sub! 'http://api.jqueryui.com/', 'https://api.jqueryui.com/'
end end
def get_latest_version(options, &block) def get_latest_version(opts)
get_npm_version('jquery-ui', options, &block) get_npm_version('jquery-ui', opts)
end end
end end
end end

@ -22,10 +22,8 @@ module Docs
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0. Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
get_latest_github_release('jsdoc3', 'jsdoc', options) do |release| get_latest_github_release('jsdoc3', 'jsdoc', opts)['tag_name']
block.call release['tag_name']
end
end end
end end
end end

@ -50,10 +50,8 @@ module Docs
html_filters.push 'julia/entries_sphinx', 'julia/clean_html_sphinx', 'sphinx/clean_html' html_filters.push 'julia/entries_sphinx', 'julia/clean_html_sphinx', 'sphinx/clean_html'
end end
def get_latest_version(options, &block) def get_latest_version(opts)
get_latest_github_release('JuliaLang', 'julia', options) do |release| get_latest_github_release('JuliaLang', 'julia', opts)['tag_name'][1..-1]
block.call release['tag_name'][1..-1]
end
end end
end end
end end

@ -34,10 +34,8 @@ module Docs
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
get_latest_github_release('knockout', 'knockout', options) do |release| get_latest_github_release('knockout', 'knockout', opts)['tag_name'][1..-1]
block.call release['tag_name'][1..-1]
end
end end
end end
end end

@ -35,8 +35,8 @@ module Docs
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
get_npm_version('koa', options, &block) get_npm_version('koa', opts)
end end
end end
end end

@ -29,10 +29,8 @@ module Docs
Licensed under the Apache License, Version 2.0. Licensed under the Apache License, Version 2.0.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
get_latest_github_release('JetBrains', 'kotlin', options) do |release| get_latest_github_release('JetBrains', 'kotlin', opts)['tag_name'][1..-1]
block.call release['tag_name'][1..-1]
end
end end
end end
end end

@ -134,10 +134,8 @@ module Docs
end end
end end
def get_latest_version(options, &block) def get_latest_version(opts)
get_latest_github_release('laravel', 'laravel', options) do |release| get_latest_github_release('laravel', 'laravel', opts)['tag_name'][1..-1]
block.call release['tag_name'][1..-1]
end
end end
end end
end end

@ -39,11 +39,10 @@ module Docs
self.base_url = "https://leafletjs.com/reference-#{release}.html" self.base_url = "https://leafletjs.com/reference-#{release}.html"
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://leafletjs.com/index.html', options) do |doc| doc = fetch_doc('https://leafletjs.com/index.html', opts)
link = doc.css('ul > li > a').to_a.select {|node| node.content == 'Docs'}.first link = doc.css('ul > li > a').to_a.select {|node| node.content == 'Docs'}.first
block.call link['href'].scan(/reference-([0-9.]+)\.html/)[0][0] link['href'].scan(/reference-([0-9.]+)\.html/)[0][0]
end
end end
end end
end end

@ -22,11 +22,10 @@ module Docs
Licensed under the Creative Commons Attribution License 3.0. Licensed under the Creative Commons Attribution License 3.0.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('http://lesscss.org/features/', options) do |doc| doc = fetch_doc('http://lesscss.org/features/', opts)
label = doc.at_css('.footer-links > li').content label = doc.at_css('.footer-links > li').content
block.call label.scan(/([0-9.]+)/)[0][0] label.scan(/([0-9.]+)/)[0][0]
end
end end
end end
end end

@ -20,10 +20,9 @@ module Docs
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
get_github_tags('Shopify', 'liquid', options) do |tags| tags = get_github_tags('Shopify', 'liquid', opts)
block.call tags[0]['name'][1..-1] tags[0]['name'][1..-1]
end
end end
end end
end end

@ -33,10 +33,9 @@ module Docs
self.base_url = "https://lodash.com/docs/#{release}" self.base_url = "https://lodash.com/docs/#{release}"
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://lodash.com/docs/', options) do |doc| doc = fetch_doc('https://lodash.com/docs/', opts)
block.call doc.at_css('#version > option[selected]').content doc.at_css('#version > option[selected]').content
end
end end
end end
end end

@ -40,10 +40,9 @@ module Docs
Licensed under the GNU Free Documentation License, Version 1.3. Licensed under the GNU Free Documentation License, Version 1.3.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://love2d.org/wiki/Version_History', options) do |doc| doc = fetch_doc('https://love2d.org/wiki/Version_History', opts)
block.call doc.at_css('#mw-content-text table a').content doc.at_css('#mw-content-text table a').content
end
end end
end end
end end

@ -27,10 +27,9 @@ module Docs
self.base_url = 'https://www.lua.org/manual/5.1/' self.base_url = 'https://www.lua.org/manual/5.1/'
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://www.lua.org/manual/', options) do |doc| doc = fetch_doc('https://www.lua.org/manual/', opts)
block.call doc.at_css('p.menubar > a').content doc.at_css('p.menubar > a').content
end
end end
end end
end end

@ -39,8 +39,8 @@ module Docs
html_filters.push 'marionette/entries_v2' html_filters.push 'marionette/entries_v2'
end end
def get_latest_version(options, &block) def get_latest_version(opts)
get_npm_version('backbone.marionette', options, &block) get_npm_version('backbone.marionette', opts)
end end
end end
end end

@ -14,8 +14,8 @@ module Docs
Licensed under the BSD License. Licensed under the BSD License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
block.call '1.0.0' '1.0.0'
end end
end end
end end

@ -65,10 +65,8 @@ module Docs
] ]
end end
def get_latest_version(options, &block) def get_latest_version(opts)
get_latest_github_release('matplotlib', 'matplotlib', options) do |release| get_latest_github_release('matplotlib', 'matplotlib', opts)['tag_name'][1..-1]
block.call release['tag_name'][1..-1]
end
end end
end end
end end

@ -21,10 +21,9 @@ module Docs
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later. Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
HTML HTML
def get_latest_version(opts, &block) def get_latest_version(opts)
fetch_json("https://developer.mozilla.org/en-US/docs/feeds/json/tag/#{options[:mdn_tag]}", opts) do |json| json = fetch_json("https://developer.mozilla.org/en-US/docs/feeds/json/tag/#{options[:mdn_tag]}", opts)
block.call DateTime.parse(json[0]['pubdate']).to_time.to_i DateTime.parse(json[0]['pubdate']).to_time.to_i
end
end end
private private

@ -46,10 +46,9 @@ module Docs
options[:fix_urls] = nil options[:fix_urls] = nil
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://docs.meteor.com/#/full/', options) do |doc| doc = fetch_doc('https://docs.meteor.com/#/full/', opts)
block.call doc.at_css('select.version-select > option').content doc.at_css('select.version-select > option').content
end
end end
end end
end end

@ -19,8 +19,8 @@ module Docs
Licensed under the Creative Commons Attribution 4.0 International License. Licensed under the Creative Commons Attribution 4.0 International License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
get_npm_version('mocha', options, &block) get_npm_version('mocha', opts)
end end
end end
end end

@ -16,8 +16,8 @@ module Docs
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
get_npm_version('modernizr', options, &block) get_npm_version('modernizr', opts)
end end
end end
end end

@ -23,10 +23,9 @@ module Docs
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('http://momentjs.com/', options) do |doc| doc = fetch_doc('http://momentjs.com/', opts)
block.call doc.at_css('.hero-title > h1 > span').content doc.at_css('.hero-title > h1 > span').content
end
end end
end end
end end

@ -27,11 +27,10 @@ module Docs
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://mongoosejs.com/docs/', options) do |doc| doc = fetch_doc('https://mongoosejs.com/docs/', opts)
label = doc.at_css('.pure-menu-link').content.strip label = doc.at_css('.pure-menu-link').content.strip
block.call label.sub(/Version /, '') label.sub(/Version /, '')
end
end end
end end
end end

@ -26,11 +26,10 @@ module Docs
Licensed under the BSD License. Licensed under the BSD License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://nginx.org/en/download.html', options) do |doc| doc = fetch_doc('https://nginx.org/en/download.html', opts)
table = doc.at_css('#content > table').inner_html table = doc.at_css('#content > table').inner_html
block.call table.scan(/nginx-([0-9.]+)</)[0][0] table.scan(/nginx-([0-9.]+)</)[0][0]
end
end end
end end
end end

@ -19,11 +19,10 @@ module Docs
Licensed under the BSD License. Licensed under the BSD License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
get_github_tags('openresty', 'lua-nginx-module', options) do |tags| tags = get_github_tags('openresty', 'lua-nginx-module', opts)
tag = tags.find { |tag| !tag['name'].include?('rc') } tag = tags.find {|tag| !tag['name'].include?('rc')}
block.call tag['name'][1..-1] tag['name'][1..-1]
end
end end
end end
end end

@ -18,10 +18,9 @@ module Docs
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://nim-lang.org/docs/overview.html', options) do |doc| doc = fetch_doc('https://nim-lang.org/docs/overview.html', opts)
block.call doc.at_css('.container > .docinfo > tbody > tr:last-child > td').content.strip doc.at_css('.container > .docinfo > tbody > tr:last-child > td').content.strip
end
end end
end end
end end

@ -47,10 +47,9 @@ module Docs
self.base_url = 'https://nodejs.org/dist/latest-v4.x/docs/api/' self.base_url = 'https://nodejs.org/dist/latest-v4.x/docs/api/'
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://nodejs.org/en/', options) do |doc| doc = fetch_doc('https://nodejs.org/en/', opts)
block.call doc.at_css('#home-intro > .home-downloadblock:last-of-type > a')['data-version'][1..-1] doc.at_css('#home-intro > .home-downloadblock:last-of-type > a')['data-version'][1..-1]
end
end end
end end
end end

@ -20,10 +20,8 @@ module Docs
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
get_latest_github_release('sparklemotion', 'nokogiri', options) do |release| get_latest_github_release('sparklemotion', 'nokogiri', opts)['tag_name'][1..-1]
block.call release['tag_name'][1..-1]
end
end end
end end
end end

@ -30,10 +30,8 @@ module Docs
npm is a trademark of npm, Inc. npm is a trademark of npm, Inc.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
get_latest_github_release('npm', 'cli', options) do |release| get_latest_github_release('npm', 'cli', opts)['tag_name'][1..-1]
block.call release['tag_name'][1..-1]
end
end end
end end
end end

@ -50,10 +50,8 @@ module Docs
self.base_url = "https://docs.scipy.org/doc/numpy-#{self.release}/reference/" self.base_url = "https://docs.scipy.org/doc/numpy-#{self.release}/reference/"
end end
def get_latest_version(options, &block) def get_latest_version(opts)
get_latest_github_release('numpy', 'numpy', options) do |release| get_latest_github_release('numpy', 'numpy', opts)['tag_name'][1..-1]
block.call release['tag_name'][1..-1]
end
end end
end end
end end

@ -87,7 +87,7 @@ module Docs
File.read(path).force_encoding('iso-8859-1').encode('utf-8') rescue nil File.read(path).force_encoding('iso-8859-1').encode('utf-8') rescue nil
end end
def get_latest_version(options, &block) def get_latest_version(opts)
latest_version = 8 latest_version = 8
current_attempt = latest_version current_attempt = latest_version
attempts = 0 attempts = 0
@ -95,17 +95,16 @@ module Docs
while attempts < 3 while attempts < 3
current_attempt += 1 current_attempt += 1
fetch_doc("https://packages.debian.org/sid/openjdk-#{current_attempt}-doc", options) do |doc| doc = fetch_doc("https://packages.debian.org/sid/openjdk-#{current_attempt}-doc", opts)
if doc.at_css('.perror').nil? if doc.at_css('.perror').nil?
latest_version = current_attempt latest_version = current_attempt
attempts = 0 attempts = 0
else else
attempts += 1 attempts += 1
end
end end
end end
block.call latest_version latest_version
end end
end end
end end

@ -19,10 +19,8 @@ module Docs
Licensed under the GNU LGPLv2.1+ and GPLv3+ licenses. Licensed under the GNU LGPLv2.1+ and GPLv3+ licenses.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
get_latest_github_release('OpenTSDB', 'opentsdb', options) do |release| get_latest_github_release('OpenTSDB', 'opentsdb', opts)['tag_name'][1..-1]
block.call release['tag_name'][1..-1]
end
end end
end end
end end

@ -24,10 +24,8 @@ module Docs
request_one(url_for('index')).body request_one(url_for('index')).body
end end
def get_latest_version(options, &block) def get_latest_version(opts)
get_github_tags('padrino', 'padrino-framework', options) do |tags| get_github_tags('padrino', 'padrino-framework', opts)[0]['name']
block.call tags[0]['name']
end
end end
end end
end end

@ -50,11 +50,10 @@ module Docs
self.base_url = "http://pandas.pydata.org/pandas-docs/version/#{self.release}/" self.base_url = "http://pandas.pydata.org/pandas-docs/version/#{self.release}/"
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('http://pandas.pydata.org/pandas-docs/stable/', options) do |doc| doc = fetch_doc('http://pandas.pydata.org/pandas-docs/stable/', opts)
label = doc.at_css('.body > .section > p').content label = doc.at_css('.body > .section > p').content
block.call label.scan(/Version: ([0-9.]+)/)[0][0] label.scan(/Version: ([0-9.]+)/)[0][0]
end
end end
end end
end end

@ -44,10 +44,9 @@ module Docs
self.base_url = "https://perldoc.perl.org/#{self.release}/" self.base_url = "https://perldoc.perl.org/#{self.release}/"
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch('https://perldoc.perl.org/static/perlversion.js', options) do |body| body = fetch('https://perldoc.perl.org/static/perlversion.js', opts)
block.call body.scan(/>Perl ([0-9.]+)/)[0][0] body.scan(/>Perl ([0-9.]+)/)[0][0]
end
end end
end end
end end

@ -30,10 +30,9 @@ module Docs
self.base_url = 'https://docs.phalconphp.com/en/2.0.0/' self.base_url = 'https://docs.phalconphp.com/en/2.0.0/'
end end
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://docs.phalconphp.com/', options) do |doc| doc = fetch_doc('https://docs.phalconphp.com/', opts)
block.call doc.at_css('.custom-select__version').content.strip.sub(/Version /, '') doc.at_css('.custom-select__version').content.strip.sub(/Version /, '')
end
end end
end end
end end

@ -26,10 +26,8 @@ module Docs
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
get_latest_github_release('photonstorm', 'phaser', options) do |release| get_latest_github_release('photonstorm', 'phaser', opts)['tag_name'][1..-1]
block.call release['tag_name'][1..-1]
end
end end
end end
end end

@ -47,10 +47,9 @@ module Docs
end end
} }
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://hexdocs.pm/phoenix/Phoenix.html', options) do |doc| doc = fetch_doc('https://hexdocs.pm/phoenix/Phoenix.html', opts)
block.call doc.at_css('.sidebar-projectVersion').content.strip[1..-1] doc.at_css('.sidebar-projectVersion').content.strip[1..-1]
end
end end
end end
end end

@ -67,11 +67,10 @@ module Docs
Licensed under the Creative Commons Attribution License v3.0 or later. Licensed under the Creative Commons Attribution License v3.0 or later.
HTML HTML
def get_latest_version(options, &block) def get_latest_version(opts)
fetch_doc('https://secure.php.net/manual/en/doc.changelog.php', options) do |doc| doc = fetch_doc('https://secure.php.net/manual/en/doc.changelog.php', opts)
label = doc.at_css('tbody.gen-changelog > tr > td').content label = doc.at_css('tbody.gen-changelog > tr > td').content
block.call label.split(',').last.strip label.split(',').last.strip
end
end end
end end
end end

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save