Class: Gem::Commands::KeepCommand

Inherits:
Gem::Command
  • Object
show all
Includes:
Prune::Util
Defined in:
lib/gem/commands/keep_command.rb

Instance Method Summary collapse

Methods included from Prune::Util

#gems_to_keep, #load_configuration, #save_configuration, #settings_filename

Constructor Details

#initializeKeepCommand

Returns a new instance of KeepCommand.



9
10
11
12
13
14
15
16
# File 'lib/gem/commands/keep_command.rb', line 9

def initialize
  super 'keep', 'Mark a gem for keeping'
  
  add_option('-v', '--version VERSION', 'Which version to keep',
    '(3.0, >=2.5, ~>1.5)') do |value, options|
    options[:version] = value
  end
end

Instance Method Details

#executeObject



18
19
20
21
22
23
24
25
# File 'lib/gem/commands/keep_command.rb', line 18

def execute
  keep_gem = get_one_gem_name
  load_configuration
  entry = gems_to_keep.detect { |(gem, versions)| gem == keep_gem }
  entry[1] << options[:version]
  entry[1] = entry[1].uniq.compact
  save_configuration
end