Class: Lapidarist::Update

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

Instance Method Summary collapse

Constructor Details

#initializeUpdate



3
4
5
6
# File 'lib/lapidarist/update.rb', line 3

def initialize
  @bundle = BundleCommand.new
  @git = GitCommand.new
end

Instance Method Details

#run(gems, attempt) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/lapidarist/update.rb', line 8

def run(gems, attempt)
  before_sha = git.head if Lapidarist.config.debug

  Lapidarist.logger.header('Updating outdated gems')

  limit =
    if Lapidarist.config.update_limit
      [Lapidarist.config.update_limit - gems.updated.length, 0].max
    else
      gems.outdated.length
    end

  updated_gems = gems.outdated.take(limit).map do |outdated_gem|
    update_gem(outdated_gem, attempt)
  end

  git.log(before_sha) if Lapidarist.config.debug

  updated_gems
end