Class: Pik::Tags

Inherits:
Command show all
Defined in:
lib/pik/commands/tag_command.rb

Instance Attribute Summary

Attributes inherited from Command

#config, #debug, #options, #output, #version

Instance Method Summary collapse

Methods inherited from Command

#actual_gem_home, #add_sigint_handler, aka, choose_from, #close, #cmd_name, cmd_name, #create, #current_gem_bin_path, #current_version?, #default_gem_home, #delete_old_pik_script, description, #editors, #find_config_from_path, #gem_path, #get_version, hl, inherited, #initialize, it, names, #pik_version, #sh, summary

Constructor Details

This class inherits a constructor from Pik::Command

Instance Method Details

#command_optionsObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/pik/commands/tag_command.rb', line 38

def command_options
  super
  sep =<<SEP
  The tags command allows you to run a subset of versions.  
  It should be used in conjunction with the run, ruby, or gems commands. 
  Multpile tags can be given in a comma separated (no spaces) list.
  
  Examples:

C:\\>pik tags jruby run ruby -v

C:\\>pik tags mingw,jruby gem install my_gem

SEP
  options.separator sep  
end

#executeObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/pik/commands/tag_command.rb', line 7

def execute
  config.global[:tags] ||= Hash.new{|h,k| h[k] = [] }
  @tag_config = config.dup
  @tag_config.clear
  abort self.class.description if @args.empty?
  
  tags = @args.shift.split(',')
  tags.each do |tag|
    versions = config.global[:tags][tag]
    raise "Tag '#{tag}' unknown" unless versions
    versions.each{|version| @tag_config[version] = config[version] }
  end
  command = Commands.find(@args.shift)
  raise "The command '#{args.join(' ')}' is unknown." unless command
  
  cmd = command.new(@args, @tag_config)
  cmd.execute
  
rescue QuitError
  puts "\nQuitting..."
rescue => e
  puts "\nThere was an error"
  puts " Error: #{e.message}\n\n"
  puts e.backtrace.map{|m| "  in: #{m}" }
ensure
  cmd.close if cmd
end

#parse_optionsObject



35
36
# File 'lib/pik/commands/tag_command.rb', line 35

def parse_options
end