lib/space/config.rb in space-0.0.3 vs lib/space/config.rb in space-0.0.4

- old
+ new

@@ -1,16 +1,24 @@ module Space class Config < Hashr class << self def load(name) - paths = %W(~/.space/#{name}.yml ./.#{name}.yml).map { |path| File.expand_path(path) } - unless path = paths.detect { |path| File.exists?(path) } - puts("Could not find #{name}.yml at either of ~/.space/#{name}.yml and ./.#{name}.yml") - exit - end - new(YAML.load(File.read(path))) + new(YAML.load(File.read(path(name)))) end + + private + + def path(name) + path = paths(name).detect { |path| File.exists?(path) } + path || raise("Could not find #{name}.yml at either of ~/.space/#{name}.yml and ./.space/#{name}.yml") + end + + def paths(name) + %w(. ~).map { |path| File.expand_path("#{path}/.space/#{name}.yml") } + end end + + define :template_dir => File.expand_path('../templates', __FILE__) def paths @paths ||= repositories.map { |path| base_dir ? "#{base_dir}/#{path}" : path } end end