devdocs/lib/docs/scrapers/cordova.rb

62 lines
1.6 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/',
2019-09-11 22:32:23 +02:00
code: 'https://github.com/apache/cordova'
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
2019-09-11 22:32:23 +02:00
&copy; 2012, 2013, 2015 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
2019-09-11 22:32:23 +02:00
version '9' do
self.release = '9.0.0'
self.base_url = "https://cordova.apache.org/docs/en/#{self.version}.x/"
end
2018-11-04 15:28:25 +01:00
version '8' do
self.release = '8.1.2'
2019-09-11 22:32:23 +02:00
self.base_url = "https://cordova.apache.org/docs/en/#{self.version}.x/"
2018-11-04 15:28:25 +01:00
end
version '7' do
2017-10-29 19:00:00 +01:00
self.release = '7.1.0'
2019-09-11 22:32:23 +02:00
self.base_url = "https://cordova.apache.org/docs/en/#{self.version}.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'
2019-09-11 22:32:23 +02:00
self.base_url = "https://cordova.apache.org/docs/en/#{self.version}.x/"
2016-09-05 19:04:09 +02:00
end
2019-03-10 03:02:24 +01:00
def get_latest_version(opts)
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]
version = version[0...-1] if version.end_with?('.')
version
end
2014-07-05 20:19:26 +02:00
end
end