6
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
34
35
36
37
38
39
40
41
|
# File 'lib/tacape/tools/helpers/json_config.rb', line 6
def setup
@config={}
@config_template.each do |k,v|
tip=' use comma, no spaces' if v.class==Array
if @config_template[k]!=nil && @config_template[k]!=''
question = "#{k} [default=#{@config_template[k]}]#{tip}:"
else
question = "#{k}#{tip}:"
end
input = ask(question)
unless input.empty?
case v
when String
@config[k]=input
when Array
@config[k]=input.split(',')
else
puts "Bailed on #{v.class}"
end
if k.include?('folder') || k.include?('file')
if File.dirname(@config[k]) == '.'
@config[k]="#{ENV['HOME']}/#{@config[k]}"
end
unless File.exist?(File.dirname(@config[k]))
FileUtils.mkdir_p(File.dirname(@config[k]))
end
end
else
@config[k]=@config_template[k]
end
end
save_config
end
|