devdocs/lib/docs/scrapers/cordova.rb

56 lines
1.5 KiB
Ruby
Raw Normal View History

2014-07-05 20:19:26 +02:00
module Docs
class Cordova < UrlScraper
self.name = 'Cordova'
self.type = 'cordova'
2016-09-05 19:04:09 +02:00
self.root_path = 'guide/overview/index.html'
2015-04-26 19:45:25 +02:00
self.links = {
home: 'https://cordova.apache.org/',
code: 'https://git-wip-us.apache.org/repos/asf/cordova-cli.git'
2015-04-26 19:45:25 +02:00
}
2014-07-05 20:19:26 +02:00
2016-09-05 19:04:09 +02:00
html_filters.push 'cordova/entries', 'cordova/clean_html'
2014-07-05 20:19:26 +02:00
2016-09-05 19:04:09 +02:00
options[:container] = '.docs'
options[:skip] = %w(index.html)
options[:fix_urls] = ->(url) do
if url.include?('https://cordova.apache.org/docs') && !url.end_with?('.html')
if url.end_with?('/')
url << 'index.html'
else
url << '/index.html'
end
end
end
2014-07-05 20:19:26 +02:00
options[:attribution] = <<-HTML
2018-11-04 15:28:25 +01:00
&copy; 2012&ndash;2018 The Apache Software Foundation<br>
2014-07-05 20:19:26 +02:00
Licensed under the Apache License 2.0.
HTML
2016-09-05 19:04:09 +02:00
2018-11-04 15:28:25 +01:00
version '8' do
self.release = '8.1.2'
self.base_url = 'https://cordova.apache.org/docs/en/8.x/'
end
version '7' do
2017-10-29 19:00:00 +01:00
self.release = '7.1.0'
self.base_url = 'https://cordova.apache.org/docs/en/7.x/'
end
2016-09-05 19:04:09 +02:00
version '6' do
2017-03-12 21:59:44 +01:00
self.release = '6.5.0'
2016-09-05 19:04:09 +02:00
self.base_url = 'https://cordova.apache.org/docs/en/6.x/'
end
def get_latest_version(options, &block)
fetch_doc('https://cordova.apache.org/docs/en/latest/', options) do |doc|
label = doc.at_css('#versionDropdown').content.strip
version = label.scan(/([0-9.]+)/)[0][0]
version = version[0...-1] if version.end_with?('.')
block.call version
end
end
2014-07-05 20:19:26 +02:00
end
end