lib/xray/config.rb in xray-rails-0.1.6 vs lib/xray/config.rb in xray-rails-0.1.7

- old
+ new

@@ -5,11 +5,11 @@ end class Config attr_accessor :editor - CONFIG_FILE = "#{Dir.home}/.xrayconfig" + CONFIG_FILE = ".xrayconfig" DEFAULT_EDITOR = '/usr/local/bin/subl' def editor load_config[:editor] end @@ -25,22 +25,30 @@ def to_yaml {editor: editor}.to_yaml end + def config_file + if File.exists?("#{Dir.pwd}/#{CONFIG_FILE}") + "#{Dir.pwd}/#{CONFIG_FILE}" + else + "#{Dir.home}/#{CONFIG_FILE}" + end + end + private def write_config(new_config) config = load_config.merge(new_config) - File.open(CONFIG_FILE, 'w') { |f| f.write(config.to_yaml) } + File.open(config_file, 'w') { |f| f.write(config.to_yaml) } end def load_config default_config.merge(local_config) end def local_config - YAML.load_file(CONFIG_FILE) + YAML.load_file(config_file) rescue {} end def default_config