lib/rbcli/util/config.rb in rbcli-0.1.1 vs lib/rbcli/util/config.rb in rbcli-0.1.2
- old
+ new
@@ -44,11 +44,11 @@
@merge_defaults = false
@categorized_defaults = nil
@loaded = false
def self.set_userfile filename, merge_defaults: false, required: false
- @config_file = filename
+ @config_file = File.expand_path filename
@merge_defaults = merge_defaults
@userfile_required = required
@loaded = false
end
@@ -74,9 +74,10 @@
@config_defaults[name.to_sym] = value
@loaded = false
end
def self.add_defaults filename=nil, text: nil
+ filename = File.expand_path filename
return unless filename and File.exists? filename
@config_text ||= ''
@config_text += "\n" unless @config_text.empty?
File.readlines(filename).each do |line|
if (line.start_with? '---' or line.start_with? '...')