class Lapidarist::Update
Attributes
bundle[R]
git[R]
outdated_gems[R]
Public Class Methods
new()
click to toggle source
# File lib/lapidarist/update.rb, line 3 def initialize @bundle = BundleCommand.new @git = GitCommand.new end
Public Instance Methods
run(gems, attempt)
click to toggle source
# 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
Private Instance Methods
update_gem(outdated_gem, attempt)
click to toggle source
# File lib/lapidarist/update.rb, line 33 def update_gem(outdated_gem, attempt) Lapidarist.logger.smart_header "Updating #{outdated_gem.name} from #{outdated_gem.installed_version}" level_constraint = Lapidarist::LevelConstraint.new(outdated_gem) bundle.update(outdated_gem, level: level_constraint.maximum) updated_version = bundle.version(outdated_gem) if git.clean? skipped_gem = Gem.from(outdated_gem, attempt: attempt, status: :skipped, reason: :nothing_to_update) Lapidarist.logger.footer "nothing to update for #{skipped_gem.name}" skipped_gem else updated_gem = Gem.from(outdated_gem, attempt: attempt, status: :updated, updated_version: updated_version) Lapidarist.logger.footer "updated #{updated_gem.name} to #{updated_gem.updated_version}" git.add('Gemfile', 'Gemfile.lock') git.commit("Update #{updated_gem.what_changed}") updated_gem end end