lib/cide/build/config.rb in cide-0.4.1 vs lib/cide/build/config.rb in cide-0.5.0
- old
+ new
@@ -68,10 +68,15 @@
def to_dockerfile
ERB.new(File.read(DOCKERFILE_TEMPLATE), nil, '<>-').result(binding)
end
+ def self.load(dir = Dir.pwd, output = $stderr)
+ file_path = find_config(dir)
+ load_file(file_path, output)
+ end
+
def self.load_file(file_path, output = $stderr)
obj = new
loader = ConfigLoader.new(obj)
loader.load YAML.load_file(file_path)
@@ -83,9 +88,16 @@
output.puts "ERROR: #{error}"
end
return obj if obj.errors.empty?
nil
+ end
+
+ def self.find_config(dir)
+ paths = CONFIG_FILES.map { |name| File.expand_path(name, dir) }
+ paths
+ .find { |path| File.exist?(path) } ||
+ fail("Config not found among these paths: #{paths.inspect}")
end
end
end
end