Class: Pik::Config
Instance Attribute Summary collapse
Attributes inherited from Command
#config, #debug, #options, #output, #version
Instance Method Summary
collapse
#initialize
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, #parse_options, #pik_version, #sh, summary
Instance Attribute Details
Returns the value of attribute global.
8
9
10
|
# File 'lib/pik/commands/config_command.rb', line 8
def global
@global
end
|
Instance Method Details
#command_options ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/pik/commands/config_command.rb', line 64
def command_options
super
sep ="If no options are given, the current and global configuration\nis displayed.\n\n Configuration options are:\n\nrubyopt on = -rubygems, off = blank \ngem_home Location of current version's GEM_HOME env. var.\ndownloads Location where 'pik install' will download new versions\ninstalls Location where 'pik install' will install new versions\n\n"
options.separator sep
end
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/pik/commands/config_command.rb', line 10
def execute
return list if @args.empty?
item, value = @args.shift.downcase.split('=')
case item
when 'rubyopt'
case value
when 'on' then set('RUBYOPT' => '-rubygems')
when 'off' then set('RUBYOPT' => nil)
end
when 'gem_home'
config[find_config_from_path][:gem_home] = if @args.include?('default')
Pathname(default_gem_home)
else
Pathname(value)
end
when 'downloads', 'download_dir'
config.global[:download_dir] = Pathname.new(value)
when 'installs', 'install_dir'
config.global[:install_dir] = Pathname.new(value)
when 'devkit', 'devkit_dir'
config.global[:devkit] = Pathname.new(value)
when 'list'
list
else
puts "Unknown configuration option"
end
end
|
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/pik/commands/config_command.rb', line 38
def list
version = find_config_from_path
puts "** CURRENT CONFIGURATION **"
puts
puts version + ' *'
config[version].each{|k,v| puts " %s: %s" % [k, v]}
puts
puts "** GLOBAL CONFIGURATION **"
puts
cfg = stringify(config.global.dup)
puts cfg.to_yaml.gsub(/"/, '')
end
|
#stringify(item) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/pik/commands/config_command.rb', line 51
def stringify(item)
case item
when Array
item.map{|i| stringify(i) }
when Hash
h = {}
item.map{|k,v| h[stringify(k)] = stringify(v)}
h
else
item.to_s
end
end
|