Class: Bundler::Dependencies::Spec
- Inherits:
-
Object
- Object
- Bundler::Dependencies::Spec
- Defined in:
- lib/bundler/dependencies/spec.rb
Constant Summary collapse
- SPECS =
rubocop:disable Style/MutableConstant
{}
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
Returns the value of attribute dependencies.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #dependency_count ⇒ Object
- #flatten ⇒ Object
- #include_dependency?(gem) ⇒ Boolean
-
#initialize(name) ⇒ Spec
constructor
A new instance of Spec.
Constructor Details
#initialize(name) ⇒ Spec
Returns a new instance of Spec.
21 22 23 24 25 26 |
# File 'lib/bundler/dependencies/spec.rb', line 21 def initialize(name) @name = name @dependencies = Graph.new SPECS[name] = self end |
Instance Attribute Details
#dependencies ⇒ Object
Returns the value of attribute dependencies.
8 9 10 |
# File 'lib/bundler/dependencies/spec.rb', line 8 def dependencies @dependencies end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/bundler/dependencies/spec.rb', line 8 def name @name end |
Class Method Details
.find(name) ⇒ Object
17 18 19 |
# File 'lib/bundler/dependencies/spec.rb', line 17 def self.find(name) SPECS[name.to_sym] end |
.new(name, dependencies = []) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/bundler/dependencies/spec.rb', line 10 def self.new(name, dependencies = []) name = name.to_sym spec = find(name) || super(name) spec.dependencies = Graph.new(specs: dependencies.map { |d| new(d) }) if dependencies.any? spec end |
Instance Method Details
#dependency_count ⇒ Object
39 40 41 |
# File 'lib/bundler/dependencies/spec.rb', line 39 def dependency_count flatten.count end |
#flatten ⇒ Object
32 33 34 35 36 37 |
# File 'lib/bundler/dependencies/spec.rb', line 32 def flatten dependencies.inject([]) do |arr, dependency| arr << dependency arr.concat(dependency.flatten) end.uniq end |
#include_dependency?(gem) ⇒ Boolean
28 29 30 |
# File 'lib/bundler/dependencies/spec.rb', line 28 def include_dependency?(gem) dependencies.include_dependency?(gem) end |