Class: LicenseFinder::BowerPackage

Inherits:
Package
  • Object
show all
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

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.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/license_finder/packages/bower_package.rb', line 7

def initialize(bower_module, options = {})
  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,
    options.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_managerObject



33
34
35
# File 'lib/license_finder/packages/bower_package.rb', line 33

def package_manager
  'Bower'
end

#package_urlObject



37
38
39
40
# File 'lib/license_finder/packages/bower_package.rb', line 37

def package_url
  meta = JSON.parse(open("https://registry.bower.io/packages/#{CGI.escape(name)}").read)
  meta['url']
end