Class: Bundler::AutoUpdate::Dependency

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler_auto_update.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, version = nil, options = nil) ⇒ Dependency

Returns a new instance of Dependency.



194
195
196
197
198
# File 'lib/bundler_auto_update.rb', line 194

def initialize(name, version = nil, options = nil)
  @name, @version, @options = name, version, options

  @major, @minor, @patch = version.split('.') if version
end

Instance Attribute Details

#majorObject (readonly)

Returns the value of attribute major.



191
192
193
# File 'lib/bundler_auto_update.rb', line 191

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



191
192
193
# File 'lib/bundler_auto_update.rb', line 191

def minor
  @minor
end

#nameObject (readonly)

Returns the value of attribute name.



191
192
193
# File 'lib/bundler_auto_update.rb', line 191

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



191
192
193
# File 'lib/bundler_auto_update.rb', line 191

def options
  @options
end

#patchObject (readonly)

Returns the value of attribute patch.



191
192
193
# File 'lib/bundler_auto_update.rb', line 191

def patch
  @patch
end

#versionObject

Returns the value of attribute version.



192
193
194
# File 'lib/bundler_auto_update.rb', line 192

def version
  @version
end

Instance Method Details

#available_versionsObject



211
212
213
214
# File 'lib/bundler_auto_update.rb', line 211

def available_versions
  the_gem_line = gem_remote_list_output.scan(/^#{name}\s.*$/).first
  the_gem_line.scan /\d+\.\d+\.\d+/
end

#gem_remote_list_outputObject



216
217
218
# File 'lib/bundler_auto_update.rb', line 216

def gem_remote_list_output
  CommandRunner.run "gem list #{name} -r -a"
end

#last_version(version_type) ⇒ Object



200
201
202
203
204
205
206
207
208
209
# File 'lib/bundler_auto_update.rb', line 200

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
  end
end