Class: LicenseFinder::Licensing
- Inherits:
-
Struct
- Object
- Struct
- LicenseFinder::Licensing
- Defined in:
- lib/license_finder/package_utils/licensing.rb
Instance Attribute Summary collapse
-
#decided_licenses ⇒ Object
Returns the value of attribute decided_licenses.
-
#license_files ⇒ Object
Returns the value of attribute license_files.
-
#licenses_from_spec ⇒ Object
Returns the value of attribute licenses_from_spec.
-
#package ⇒ Object
Returns the value of attribute package.
Instance Method Summary collapse
-
#activations ⇒ Object
Implements the algorithm for choosing the right set of licenses from among the various sources of licenses we know about.
- #activations_from_decisions ⇒ Object
- #activations_from_files ⇒ Object
- #activations_from_spec ⇒ Object
- #default_activation ⇒ Object
Instance Attribute Details
#decided_licenses ⇒ Object
Returns the value of attribute decided_licenses
6 7 8 |
# File 'lib/license_finder/package_utils/licensing.rb', line 6 def decided_licenses @decided_licenses end |
#license_files ⇒ Object
Returns the value of attribute license_files
6 7 8 |
# File 'lib/license_finder/package_utils/licensing.rb', line 6 def license_files @license_files end |
#licenses_from_spec ⇒ Object
Returns the value of attribute licenses_from_spec
6 7 8 |
# File 'lib/license_finder/package_utils/licensing.rb', line 6 def licenses_from_spec @licenses_from_spec end |
#package ⇒ Object
Returns the value of attribute package
6 7 8 |
# File 'lib/license_finder/package_utils/licensing.rb', line 6 def package @package end |
Instance Method Details
#activations ⇒ Object
Implements the algorithm for choosing the right set of licenses from among the various sources of licenses we know about. In order of priority, licenses come from decisions, package specs, or package files.
10 11 12 13 14 15 16 |
# File 'lib/license_finder/package_utils/licensing.rb', line 10 def activations if activations_from_decisions.any? then activations_from_decisions elsif activations_from_spec.any? then activations_from_spec elsif activations_from_files.any? then activations_from_files else [default_activation] end end |
#activations_from_decisions ⇒ Object
18 19 20 21 |
# File 'lib/license_finder/package_utils/licensing.rb', line 18 def activations_from_decisions @activations_from_decisions ||= decided_licenses .map { |license| Activation::FromDecision.new(package, license) } end |
#activations_from_files ⇒ Object
28 29 30 31 32 |
# File 'lib/license_finder/package_utils/licensing.rb', line 28 def activations_from_files @activations_from_files ||= license_files .group_by(&:license) .map { |license, files| Activation::FromFiles.new(package, license, files) } end |
#activations_from_spec ⇒ Object
23 24 25 26 |
# File 'lib/license_finder/package_utils/licensing.rb', line 23 def activations_from_spec @activations_from_spec ||= licenses_from_spec .map { |license| Activation::FromSpec.new(package, license) } end |
#default_activation ⇒ Object
34 35 36 37 |
# File 'lib/license_finder/package_utils/licensing.rb', line 34 def default_activation default_license = License.find_by_name nil Activation::None.new(package, default_license) end |