Class: LicenseFinder::BowerPackage
- Defined in:
- lib/license_finder/packages/bower_package.rb
Instance Attribute Summary
Attributes inherited from Package
#authors, #children, #description, #groups, #homepage, #install_path, #license_names_from_spec, #logger, #manual_approval, #name, #parents, #summary, #version
Instance Method Summary collapse
-
#initialize(bower_module, options = {}) ⇒ BowerPackage
constructor
A new instance of BowerPackage.
- #package_manager ⇒ Object
- #package_url ⇒ Object
Methods inherited from Package
#<=>, #activations, #approved?, #approved_manually!, #approved_manually?, #decide_on_license, #eql?, #hash, #license_files, license_names_from_standard_spec, #licenses, #licenses_from_spec, #licensing, #log_activation, #missing?, #notice_files, #permitted!, #permitted?, #restricted!, #restricted?
Constructor Details
#initialize(bower_module, options = {}) ⇒ BowerPackage
Returns a new instance of BowerPackage.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/license_finder/packages/bower_package.rb', line 6 def initialize(bower_module, = {}) spec = bower_module.fetch('pkgMeta', {}) if spec.empty? endpoint = bower_module.fetch('endpoint', {}) name = endpoint['name'] version = endpoint['target'] else name = spec['name'] version = spec['version'] end super( name, version, .merge( summary: spec['description'], description: spec['readme'], homepage: spec['homepage'], spec_licenses: Package.license_names_from_standard_spec(spec), install_path: bower_module['canonicalDir'], missing: bower_module['missing'] ) ) end |
Instance Method Details
#package_manager ⇒ Object
32 33 34 |
# File 'lib/license_finder/packages/bower_package.rb', line 32 def package_manager 'Bower' end |
#package_url ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/license_finder/packages/bower_package.rb', line 36 def package_url = if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.5.0') JSON.parse(open("https://registry.bower.io/packages/#{CGI.escape(name)}").read) else JSON.parse(URI.open("https://registry.bower.io/packages/#{CGI.escape(name)}").read) end ['url'] end |