Class: Gemkeeper::Configuration::GemDefinition
- Inherits:
-
Object
- Object
- Gemkeeper::Configuration::GemDefinition
- Defined in:
- lib/gemkeeper/configuration.rb
Overview
Keeps per-gem config strongly typed so callers get validated attributes instead of raw hash access.
Constant Summary collapse
- VALID_VERSION_PATTERN =
/\A[a-zA-Z0-9._-]+\z/- RESERVED_VERSIONS =
%w[latest from_lockfile].freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #from_lockfile? ⇒ Boolean
-
#initialize(config) ⇒ GemDefinition
constructor
A new instance of GemDefinition.
- #latest? ⇒ Boolean
Constructor Details
#initialize(config) ⇒ GemDefinition
Returns a new instance of GemDefinition.
129 130 131 132 133 134 135 136 |
# File 'lib/gemkeeper/configuration.rb', line 129 def initialize(config) @repo = config[:repo] @name = config[:name] || extract_name_from_repo raise InvalidConfigError, "Gem definition needs a 'name' or 'repo'" unless @name @version = config[:version] || "latest" validate_version! end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
127 128 129 |
# File 'lib/gemkeeper/configuration.rb', line 127 def name @name end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
127 128 129 |
# File 'lib/gemkeeper/configuration.rb', line 127 def repo @repo end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
127 128 129 |
# File 'lib/gemkeeper/configuration.rb', line 127 def version @version end |
Instance Method Details
#from_lockfile? ⇒ Boolean
142 143 144 |
# File 'lib/gemkeeper/configuration.rb', line 142 def from_lockfile? @version == "from_lockfile" end |
#latest? ⇒ Boolean
138 139 140 |
# File 'lib/gemkeeper/configuration.rb', line 138 def latest? @version == "latest" end |