Class: Devpack::GemRef
- Inherits:
-
Object
- Object
- Devpack::GemRef
- Defined in:
- lib/devpack/gem_ref.rb
Overview
Provides extended syntax for gem definitions, allowing ‘require: false` semantics via an asterisrk prefix in `.devpack` file, e.g. `*my_gem`
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
-
#initialize(name:, version: nil, no_require: false) ⇒ GemRef
constructor
A new instance of GemRef.
- #require? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(name:, version: nil, no_require: false) ⇒ GemRef
Returns a new instance of GemRef.
14 15 16 17 18 |
# File 'lib/devpack/gem_ref.rb', line 14 def initialize(name:, version: nil, no_require: false) @name = name @version = version @no_require = no_require end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
20 21 22 |
# File 'lib/devpack/gem_ref.rb', line 20 def name @name end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
20 21 22 |
# File 'lib/devpack/gem_ref.rb', line 20 def version @version end |
Class Method Details
.parse(line) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/devpack/gem_ref.rb', line 7 def self.parse(line) name, _, version = line.partition(':') no_require = name.start_with?('*') name = name.sub('*', '') if no_require new(name: name, version: version.empty? ? nil : Gem::Requirement.new(version), no_require: no_require) end |
Instance Method Details
#eql?(other) ⇒ Boolean
26 27 28 |
# File 'lib/devpack/gem_ref.rb', line 26 def eql?(other) name == other.name && version == other.version && require? == other.require? end |
#require? ⇒ Boolean
22 23 24 |
# File 'lib/devpack/gem_ref.rb', line 22 def require? !@no_require end |
#to_s ⇒ Object
30 31 32 |
# File 'lib/devpack/gem_ref.rb', line 30 def to_s "#{require? ? '*' : ''}#{@name}:#{@version}" end |