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
|
# File 'lib/ufo/config/parse.rb', line 12
def for(config, type: :boolean)
lines = IO.readlines("#{Ufo.root}/.ufo/config.rb")
config_line = lines.find do |l|
regexp = Regexp.new("config\.#{config}.*=")
l =~ regexp && l !~ /^\s+#/
end
return false unless config_line config_value = config_line.gsub(/.*=/,'').strip.gsub(/["']/,'')
case type
when :array
eval(config_value) when :boolean
config_value != "false" && config_value != "nil"
when :string
config_value.sub(/\s+#.*/,'') else
raise "Type #{type.inspect} not supported"
end
rescue Exception => e
puts "#{e.class} #{e.message}".color(:yellow)
puts "WARN: Unable to parse for config.layering.show".color(:yellow)
puts "Using default: config.layering.show = false"
false
end
|