Class: Bundler::AutoUpdate::GemUpdater

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gem, gemfile, test_command) ⇒ GemUpdater

Returns a new instance of GemUpdater.



44
45
46
# File 'lib/bundler_auto_update.rb', line 44

def initialize(gem, gemfile, test_command)
  @gem, @gemfile, @test_command = gem, gemfile, test_command
end

Instance Attribute Details

#gemObject (readonly)

Returns the value of attribute gem.



42
43
44
# File 'lib/bundler_auto_update.rb', line 42

def gem
  @gem
end

#gemfileObject (readonly)

Returns the value of attribute gemfile.



42
43
44
# File 'lib/bundler_auto_update.rb', line 42

def gemfile
  @gemfile
end

#test_commandObject (readonly)

Returns the value of attribute test_command.



42
43
44
# File 'lib/bundler_auto_update.rb', line 42

def test_command
  @test_command
end

Instance Method Details

#auto_updateObject



48
49
50
51
52
53
54
55
# File 'lib/bundler_auto_update.rb', line 48

def auto_update
  if updatable?
    Logger.log "Updating #{gem.name}"
    update(:patch) and update(:minor) and update(:major)
  else
    Logger.log "#{gem.name} is not auto-updatable, passing it."
  end
end

#update(version_type) ⇒ Boolean

Returns true on success or when already at latest version.

Returns:

  • (Boolean)

    true on success or when already at latest version



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/bundler_auto_update.rb', line 58

def update(version_type)
  new_version = gem.last_version(version_type)

  if new_version == gem.version
    Logger.log_indent "Current gem already at latest #{version_type} version. Passing this update."

    return true
  end

  Logger.log_indent "Updating to #{version_type} version #{new_version}"

  gem.version = new_version

  (update_gemfile and run_test_suite and commit_new_version) or revert_to_previous_version
end