Class: RubocopChallenger::Bundler::Command

Inherits:
Object
  • Object
show all
Includes:
PrComet::CommandLine
Defined in:
lib/rubocop_challenger/bundler/command.rb

Overview

To execute bundler command

Instance Method Summary collapse

Constructor Details

#initialize(verbose: false) ⇒ Command

Returns a new instance of Command.



9
10
11
# File 'lib/rubocop_challenger/bundler/command.rb', line 9

def initialize(verbose: false)
  @verbose = verbose
end

Instance Method Details

#installed?(gem_name) ⇒ Boolean

Checks the gem is installed

Returns:

  • (Boolean)

    Returns true if installed



26
27
28
# File 'lib/rubocop_challenger/bundler/command.rb', line 26

def installed?(gem_name)
  !run('list', '|', 'grep', "' #{gem_name} '").empty?
end

#update(*gem_names) ⇒ Object

Executes ‘$ bundle update` which excludes not installed gems

Parameters:

  • gem_names (Array<String>)

    The target gem names



16
17
18
19
20
21
# File 'lib/rubocop_challenger/bundler/command.rb', line 16

def update(*gem_names)
  target_gems = gem_names.select { |gem_name| installed?(gem_name) }
  return if target_gems.empty?

  run('update', *target_gems, '--conservative')
end