Class: Bundler::AutoUpdate::Dependency
- Inherits:
-
Object
- Object
- Bundler::AutoUpdate::Dependency
- Defined in:
- lib/bundler_auto_update.rb
Instance Attribute Summary collapse
-
#major ⇒ Object
readonly
Returns the value of attribute major.
-
#minor ⇒ Object
readonly
Returns the value of attribute minor.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#patch ⇒ Object
readonly
Returns the value of attribute patch.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#available_versions ⇒ Array
Return an ordered array of all available versions.
-
#initialize(name, version = nil, options = nil) ⇒ Dependency
constructor
A new instance of Dependency.
-
#last_version(version_type) ⇒ String
Return last version scoped at :version_type:.
Constructor Details
#initialize(name, version = nil, options = nil) ⇒ Dependency
Returns a new instance of Dependency.
236 237 238 239 240 241 |
# File 'lib/bundler_auto_update.rb', line 236 def initialize(name, version = nil, = nil) @name, @version, @options = name, version, # TODO: enhance support of > and ~> in versions @major, @minor, @patch = version[/\d+\.\d+(\.\d+)?/].split('.') if version end |
Instance Attribute Details
#major ⇒ Object (readonly)
Returns the value of attribute major.
233 234 235 |
# File 'lib/bundler_auto_update.rb', line 233 def major @major end |
#minor ⇒ Object (readonly)
Returns the value of attribute minor.
233 234 235 |
# File 'lib/bundler_auto_update.rb', line 233 def minor @minor end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
233 234 235 |
# File 'lib/bundler_auto_update.rb', line 233 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
233 234 235 |
# File 'lib/bundler_auto_update.rb', line 233 def @options end |
#patch ⇒ Object (readonly)
Returns the value of attribute patch.
233 234 235 |
# File 'lib/bundler_auto_update.rb', line 233 def patch @patch end |
#version ⇒ Object
Returns the value of attribute version.
234 235 236 |
# File 'lib/bundler_auto_update.rb', line 234 def version @version end |
Instance Method Details
#available_versions ⇒ Array
Return an ordered array of all available versions.
266 267 268 269 |
# File 'lib/bundler_auto_update.rb', line 266 def available_versions the_gem_line = gem_remote_list_output.scan(/^#{name}\s.*$/).first the_gem_line.scan /\d+\.\d+\.\d+/ end |
#last_version(version_type) ⇒ String
Return last version scoped at :version_type:.
Example: last_version(:patch), returns the last patch version for the current major/minor version
250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/bundler_auto_update.rb', line 250 def last_version(version_type) case version_type when :patch available_versions.select { |v| v =~ /^#{major}\.#{minor}\D/ }.first when :minor available_versions.select { |v| v =~ /^#{major}\./ }.first when :major available_versions.first else raise "Invalid version_type: #{version_type}" end end |