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



23
24
25
# File 'lib/rubocop_challenger/bundler/command.rb', line 23

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
# File 'lib/rubocop_challenger/bundler/command.rb', line 16

def update(*gem_names)
  run('update', *gem_names.select { |gem_name| installed?(gem_name) }, '--conservative')
end