class Lumise::Commands::Rubocop::UpdateGems

Attributes

plugins[R]

Public Class Methods

call(plugins:) click to toggle source
# File lib/lumise/services/commands/rubocop/update_gems.rb, line 11
def self.call(plugins:)
  new(plugins: plugins).send :perform
end
new(plugins:) click to toggle source
# File lib/lumise/services/commands/rubocop/update_gems.rb, line 15
def initialize(plugins:)
  @plugins = plugins
end

Private Instance Methods

bundle_update() click to toggle source
# File lib/lumise/services/commands/rubocop/update_gems.rb, line 30
def bundle_update
  command(printer: :quiet).run(bundle_update_command)
rescue TTY::Command::ExitError, StandardError => e
  # Could not find gem 'rubocop'.
  #
  # Could not locate Gemfile
  #
  # This Bundle hasn't been installed yet. Run `bundle install` to
  # update and install the bundled gems.

  logger.error e.message
  exit 1
end
bundle_update_command() click to toggle source
# File lib/lumise/services/commands/rubocop/update_gems.rb, line 52
def bundle_update_command
  "bundle update --conservative rubocop #{gems}"
end
gems() click to toggle source
# File lib/lumise/services/commands/rubocop/update_gems.rb, line 56
def gems
  plugins.map do |plugin|
    'rubocop-' + plugin
  end.join(' ')
end
perform() click to toggle source
# File lib/lumise/services/commands/rubocop/update_gems.rb, line 23
def perform
  if yes?
    logger.info "#Running #{bundle_update_command}"
    bundle_update
  end
end
yes?() click to toggle source
# File lib/lumise/services/commands/rubocop/update_gems.rb, line 44
def yes?
  if l.update_gems.nil?
    prompt.yes? 'Update rubocop gems?', suffix: 'Yeah/nah'
  else
    l.update_gems
  end
end