Class: LicenseFinder::NpmPackage
- Defined in:
- lib/license_finder/packages/npm_package.rb
Defined Under Namespace
Classes: Group, Identifier, PackageJson
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
Returns the value of attribute dependencies.
-
#groups ⇒ Object
Returns the value of attribute groups.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#json ⇒ Object
Returns the value of attribute json.
Attributes inherited from Package
#authors, #children, #description, #homepage, #install_path, #license_names_from_spec, #logger, #manual_approval, #name, #parents, #summary, #version
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(npm_json) ⇒ NpmPackage
constructor
A new instance of NpmPackage.
- #package_manager ⇒ Object
- #to_s ⇒ Object
Methods inherited from Package
#<=>, #activations, #approved?, #approved_manually!, #approved_manually?, #blacklisted!, #blacklisted?, #decide_on_license, #eql?, #hash, #license_files, license_names_from_standard_spec, #licenses, #licenses_from_spec, #licensing, #log_activation, #missing?, #whitelisted!, #whitelisted?
Constructor Details
#initialize(npm_json) ⇒ NpmPackage
Returns a new instance of NpmPackage.
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/license_finder/packages/npm_package.rb', line 57 def initialize(npm_json) @json = npm_json @identifier = Identifier.from_hash(npm_json) @dependencies = deps_from_json super(@identifier.name, @identifier.version, description: npm_json['description'], homepage: npm_json['homepage'], spec_licenses: Package.license_names_from_standard_spec(npm_json), install_path: npm_json['path'], children: @dependencies.map(&:name)) end |
Instance Attribute Details
#dependencies ⇒ Object
Returns the value of attribute dependencies.
3 4 5 |
# File 'lib/license_finder/packages/npm_package.rb', line 3 def dependencies @dependencies end |
#groups ⇒ Object
Returns the value of attribute groups.
3 4 5 |
# File 'lib/license_finder/packages/npm_package.rb', line 3 def groups @groups end |
#identifier ⇒ Object
Returns the value of attribute identifier.
3 4 5 |
# File 'lib/license_finder/packages/npm_package.rb', line 3 def identifier @identifier end |
#json ⇒ Object
Returns the value of attribute json.
3 4 5 |
# File 'lib/license_finder/packages/npm_package.rb', line 3 def json @json end |
Class Method Details
.packages_from_json(npm_json, package_path) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/license_finder/packages/npm_package.rb', line 6 def packages_from_json(npm_json, package_path) @packages = flattened_dependencies(npm_json) package_json = PackageJson.new(package_path) populate_groups(package_json) @packages.values end |
Instance Method Details
#==(other) ⇒ Object
70 71 72 |
# File 'lib/license_finder/packages/npm_package.rb', line 70 def ==(other) other.is_a?(NpmPackage) && @identifier == other.identifier end |
#package_manager ⇒ Object
78 79 80 |
# File 'lib/license_finder/packages/npm_package.rb', line 78 def package_manager 'Npm' end |
#to_s ⇒ Object
74 75 76 |
# File 'lib/license_finder/packages/npm_package.rb', line 74 def to_s @identifier.to_s end |