Class: LicenseFinder::BundledGem
- Inherits:
-
Object
- Object
- LicenseFinder::BundledGem
- Defined in:
- lib/license_finder/bundled_gem.rb
Instance Attribute Summary collapse
-
#bundler_dependency ⇒ Object
readonly
Returns the value of attribute bundler_dependency.
-
#parents ⇒ Object
readonly
Returns the value of attribute parents.
-
#spec ⇒ Object
readonly
Returns the value of attribute spec.
Instance Method Summary collapse
- #children ⇒ Object
- #dependency_name ⇒ Object
- #dependency_version ⇒ Object
- #determine_license ⇒ Object
-
#initialize(spec, bundler_dependency = nil) ⇒ BundledGem
constructor
A new instance of BundledGem.
- #license_files ⇒ Object
- #name ⇒ Object
- #save_or_merge ⇒ Object
- #sort_order ⇒ Object
Constructor Details
#initialize(spec, bundler_dependency = nil) ⇒ BundledGem
Returns a new instance of BundledGem.
5 6 7 8 |
# File 'lib/license_finder/bundled_gem.rb', line 5 def initialize(spec, bundler_dependency = nil) @spec = spec @bundler_dependency = bundler_dependency end |
Instance Attribute Details
#bundler_dependency ⇒ Object (readonly)
Returns the value of attribute bundler_dependency.
3 4 5 |
# File 'lib/license_finder/bundled_gem.rb', line 3 def bundler_dependency @bundler_dependency end |
#parents ⇒ Object (readonly)
Returns the value of attribute parents.
3 4 5 |
# File 'lib/license_finder/bundled_gem.rb', line 3 def parents @parents end |
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
3 4 5 |
# File 'lib/license_finder/bundled_gem.rb', line 3 def spec @spec end |
Instance Method Details
#children ⇒ Object
26 27 28 |
# File 'lib/license_finder/bundled_gem.rb', line 26 def children @children ||= @spec.dependencies.collect(&:name) end |
#dependency_name ⇒ Object
18 19 20 |
# File 'lib/license_finder/bundled_gem.rb', line 18 def dependency_name @spec.name end |
#dependency_version ⇒ Object
22 23 24 |
# File 'lib/license_finder/bundled_gem.rb', line 22 def dependency_version @spec.version.to_s end |
#determine_license ⇒ Object
30 31 32 33 34 |
# File 'lib/license_finder/bundled_gem.rb', line 30 def determine_license return @spec.license if @spec.license license_files.map(&:license).compact.first || 'other' end |
#license_files ⇒ Object
36 37 38 |
# File 'lib/license_finder/bundled_gem.rb', line 36 def license_files LicenseFiles.new(@spec.full_gem_path).files end |
#name ⇒ Object
10 11 12 |
# File 'lib/license_finder/bundled_gem.rb', line 10 def name "#{dependency_name} #{dependency_version}" end |
#save_or_merge ⇒ Object
44 45 46 |
# File 'lib/license_finder/bundled_gem.rb', line 44 def save_or_merge GemSaver.find_or_initialize_by_name(@spec.name, self).save end |
#sort_order ⇒ Object
40 41 42 |
# File 'lib/license_finder/bundled_gem.rb', line 40 def sort_order dependency_name.downcase end |