Class: Bibliothecary::Dependency
- Inherits:
-
Object
- Object
- Bibliothecary::Dependency
- Defined in:
- lib/bibliothecary/dependency.rb
Overview
Dependency represents a single unique dependency that was parsed out of a manifest.
Constant Summary collapse
- FIELDS =
[ :name, :requirement, :original_requirement, :platform, :type, :direct, :deprecated, :local, :optional, :original_name, :source, ]
Instance Attribute Summary collapse
-
#deprecated ⇒ Boolean
readonly
Is this dependency deprecated? (default: nil).
-
#direct ⇒ Boolean
readonly
Is this dependency a direct dependency (vs transitive dependency)? (default: nil).
-
#local ⇒ Boolean
readonly
Is this dependency local? (default: nil).
-
#name ⇒ String
readonly
The name of the package, e.g.
-
#optional ⇒ Boolean
readonly
Is this dependency optional? (default: nil).
-
#original_name ⇒ String
readonly
The original name used to require the dependency, for cases where it did not match the resolved name.
-
#original_requirement ⇒ String
readonly
The original requirement used to require the dependency, for cases where it did not match the resolved name.
-
#platform ⇒ String
readonly
The platform of the package, e.g.
-
#requirement ⇒ String
readonly
The version requirement of the release, e.g.
-
#type ⇒ String
readonly
The type of dependency, e.g.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(name:, requirement:, original_requirement: nil, platform: nil, type: nil, direct: nil, deprecated: nil, local: nil, optional: nil, original_name: nil, source: nil) ⇒ Dependency
constructor
A new instance of Dependency.
- #to_h ⇒ Object
Constructor Details
#initialize(name:, requirement:, original_requirement: nil, platform: nil, type: nil, direct: nil, deprecated: nil, local: nil, optional: nil, original_name: nil, source: nil) ⇒ Dependency
Returns a new instance of Dependency.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/bibliothecary/dependency.rb', line 38 def initialize( name:, requirement:, original_requirement: nil, platform: nil, type: nil, direct: nil, deprecated: nil, local: nil, optional: nil, original_name: nil, source: nil ) @name = name @platform = platform @requirement = requirement || "*" @original_requirement = original_requirement @type = type @direct = direct @deprecated = deprecated @local = local @optional = optional @original_name = original_name @source = source end |
Instance Attribute Details
#deprecated ⇒ Boolean (readonly)
Is this dependency deprecated? (default: nil)
21 22 23 |
# File 'lib/bibliothecary/dependency.rb', line 21 def deprecated @deprecated end |
#direct ⇒ Boolean (readonly)
Is this dependency a direct dependency (vs transitive dependency)? (default: nil)
21 22 23 |
# File 'lib/bibliothecary/dependency.rb', line 21 def direct @direct end |
#local ⇒ Boolean (readonly)
Is this dependency local? (default: nil)
21 22 23 |
# File 'lib/bibliothecary/dependency.rb', line 21 def local @local end |
#name ⇒ String (readonly)
The name of the package, e.g. “ansi-string-colors”
21 22 23 |
# File 'lib/bibliothecary/dependency.rb', line 21 def name @name end |
#optional ⇒ Boolean (readonly)
Is this dependency optional? (default: nil)
21 22 23 |
# File 'lib/bibliothecary/dependency.rb', line 21 def optional @optional end |
#original_name ⇒ String (readonly)
The original name used to require the dependency, for cases where it did not match the resolved name. This can be used for features like aliasing.
21 22 23 |
# File 'lib/bibliothecary/dependency.rb', line 21 def original_name @original_name end |
#original_requirement ⇒ String (readonly)
The original requirement used to require the dependency, for cases where it did not match the resolved name. This can be used for features like aliasing.
21 22 23 |
# File 'lib/bibliothecary/dependency.rb', line 21 def original_requirement @original_requirement end |
#platform ⇒ String (readonly)
The platform of the package, e.g. “maven”. This is optional because it’s implicit in most parser results, and the analyzer returns the platform name itself. One exception are multi-parsers like DependenciesCSV, because they may return deps from multiple platforms. Bibliothecary could start returning this field for all deps in future, and make it required. (default: nil)
21 22 23 |
# File 'lib/bibliothecary/dependency.rb', line 21 def platform @platform end |
#requirement ⇒ String (readonly)
The version requirement of the release, e.g. “1.0.0” or “^1.0.0”
21 22 23 |
# File 'lib/bibliothecary/dependency.rb', line 21 def requirement @requirement end |
#type ⇒ String (readonly)
The type of dependency, e.g. “runtime” or “test”
21 22 23 |
# File 'lib/bibliothecary/dependency.rb', line 21 def type @type end |
Instance Method Details
#[](key) ⇒ Object
69 70 71 |
# File 'lib/bibliothecary/dependency.rb', line 69 def [](key) public_send(key) end |
#eql?(other) ⇒ Boolean Also known as: ==
64 65 66 |
# File 'lib/bibliothecary/dependency.rb', line 64 def eql?(other) FIELDS.all? { |f| public_send(f) == other.public_send(f) } end |
#hash ⇒ Object
77 78 79 |
# File 'lib/bibliothecary/dependency.rb', line 77 def hash FIELDS.map { |f| public_send(f) }.hash end |
#to_h ⇒ Object
73 74 75 |
# File 'lib/bibliothecary/dependency.rb', line 73 def to_h FIELDS.to_h { |f| [f, public_send(f)] } end |