lib/retrospec/config.rb in retrospec-0.2.1 vs lib/retrospec/config.rb in retrospec-0.3.0
- old
+ new
@@ -8,30 +8,30 @@
include Retrospec::Plugins::V1
attr_accessor :config_file
# we should be able to lookup where the user stores the config map
# so the user doesn't have to pass this info each time
- def initialize(file=nil, opts={})
+ def initialize(file=default_config_file, opts={})
setup_config_file(file)
end
# create a blank yaml config file it file does not exist
def setup_config_file(file=nil)
if file.nil? or ! File.exists?(file)
# config does not exist
setup_config_dir
- dst_file = File.join(default_retrospec_dir, 'config.yaml.sample')
+ dst_file = File.join(default_retrospec_dir, 'config.yaml')
src_file = File.join(gem_dir,'config.yaml.sample')
safe_copy_file(src_file, dst_file)
file = dst_file
end
@config_file = file
end
# loads the config data into a ruby object
def config_data
- @config_data ||= YAML.load_file(config_file)
+ @config_data ||= YAML.load_file(config_file) || {}
end
def self.config_data(file)
new(file).config_data
end
@@ -44,9 +44,13 @@
def gem_dir
File.expand_path("../../../", __FILE__)
end
private
+
+ def default_config_file
+ File.join(default_retrospec_dir, 'config.yaml')
+ end
def setup_config_dir
FileUtils.mkdir_p(File.expand_path(default_retrospec_dir)) unless File.directory?(default_retrospec_dir)
end
end
\ No newline at end of file