devdocs/lib/docs/scrapers/npm.rb

40 lines
1,020 B
Ruby
Raw Normal View History

2015-04-26 22:48:46 +02:00
module Docs
class Npm < UrlScraper
self.name = 'npm'
self.type = 'npm'
2018-08-20 00:01:09 +02:00
self.release = '6.4.0'
2015-04-26 22:48:46 +02:00
self.base_url = 'https://docs.npmjs.com/'
2016-11-13 17:18:02 +01:00
self.force_gzip = true
2015-04-26 22:48:46 +02:00
self.links = {
home: 'https://www.npmjs.com/',
code: 'https://github.com/npm/npm'
}
html_filters.push 'npm/entries', 'npm/clean_html', 'title'
2017-07-16 23:39:28 +02:00
options[:max_image_size] = 130_000
2015-04-26 22:48:46 +02:00
options[:container] = ->(filter) { filter.root_page? ? '.toc' : nil }
options[:title] = false
options[:root_title] = 'npm'
2015-11-21 17:38:35 +01:00
options[:skip] = %w(all misc/index)
2015-04-26 22:48:46 +02:00
options[:skip_patterns] = [
/\Aenterprise/,
/\Acompany/,
/\Apolicies/
]
options[:attribution] = <<-HTML
&copy; npm, Inc. and Contributors<br>
Licensed under the npm License.<br>
npm is a trademark of npm, Inc.
HTML
def get_latest_version(options, &block)
get_latest_github_release('npm', 'cli', options) do |release|
block.call release['tag_name'][1..-1]
end
end
2015-04-26 22:48:46 +02:00
end
end