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.



181
182
183
184
185
# File 'lib/bundler_auto_update.rb', line 181

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.



178
179
180
# File 'lib/bundler_auto_update.rb', line 178

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



178
179
180
# File 'lib/bundler_auto_update.rb', line 178

def minor
  @minor
end

#nameObject (readonly)

Returns the value of attribute name.



178
179
180
# File 'lib/bundler_auto_update.rb', line 178

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



178
179
180
# File 'lib/bundler_auto_update.rb', line 178

def options
  @options
end

#patchObject (readonly)

Returns the value of attribute patch.



178
179
180
# File 'lib/bundler_auto_update.rb', line 178

def patch
  @patch
end

#versionObject

Returns the value of attribute version.



179
180
181
# File 'lib/bundler_auto_update.rb', line 179

def version
  @version
end

Instance Method Details

#available_versionsObject



198
199
200
201
# File 'lib/bundler_auto_update.rb', line 198

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



203
204
205
# File 'lib/bundler_auto_update.rb', line 203

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

#last_version(version_type) ⇒ Object



187
188
189
190
191
192
193
194
195
196
# File 'lib/bundler_auto_update.rb', line 187

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