lib/rbcli/configuration/config.rb in rbcli-0.1.7 vs lib/rbcli/configuration/config.rb in rbcli-0.1.8

- old
+ new

@@ -43,11 +43,11 @@ @config_defaults = nil @merge_defaults = false @categorized_defaults = nil @loaded = false - def self.set_userfile filename, merge_defaults: false, required: false + def self.set_userfile filename, merge_defaults: true, required: false @config_file = File.expand_path filename @merge_defaults = merge_defaults @userfile_required = required @loaded = false end @@ -65,25 +65,25 @@ @config_defaults[name.to_sym][k.to_sym] = v[:value] end @loaded = false end - def self.add_default name, description: nil, value: nil + def self.add_default name, description: nil, default: nil @config_individual_lines ||= [] - text = "#{name.to_s}: #{value}".ljust(30) + " # #{description}" + text = "#{name.to_s}: #{default}".ljust(30) + " # #{description}" @config_individual_lines.push text unless @config_individual_lines.include? text - @config_defaults[name.to_sym] = value + @config_defaults[name.to_sym] = default @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? '...') - @config_text << "\n\n" + if line.start_with? '---' or line.start_with? '...' + @config_text << "\n" unless @config_text.empty? else @config_text << line unless @config_text.include? line end end if filename and File.exists? filename @config_text << "\n\n" << text if text