Class: Gemkeeper::Configuration::GemDefinition

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ GemDefinition

Returns a new instance of GemDefinition.



122
123
124
125
126
127
# File 'lib/gemkeeper/configuration.rb', line 122

def initialize(config)
  @repo = config[:repo] or raise InvalidConfigError, "Gem definition missing 'repo'"
  @version = config[:version] || "latest"
  @name = config[:name] || extract_name_from_repo
  validate_version!
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



120
121
122
# File 'lib/gemkeeper/configuration.rb', line 120

def name
  @name
end

#repoObject (readonly)

Returns the value of attribute repo.



120
121
122
# File 'lib/gemkeeper/configuration.rb', line 120

def repo
  @repo
end

#versionObject (readonly)

Returns the value of attribute version.



120
121
122
# File 'lib/gemkeeper/configuration.rb', line 120

def version
  @version
end

Instance Method Details

#from_lockfile?Boolean

Returns:

  • (Boolean)


133
134
135
# File 'lib/gemkeeper/configuration.rb', line 133

def from_lockfile?
  @version == "from_lockfile"
end

#latest?Boolean

Returns:

  • (Boolean)


129
130
131
# File 'lib/gemkeeper/configuration.rb', line 129

def latest?
  @version == "latest"
end