class CIDE::ConfigFile

Constants

DOCKERFILE_TEMPLATE

Attributes

errors[R]
warnings[R]

Public Class Methods

find_config(dir) click to toggle source
# File lib/cide/config_file.rb, line 101
def self.find_config(dir)
  paths = CONFIG_FILES.map { |name| File.expand_path(name, dir) }
  paths
    .find { |path| File.exist?(path) } ||
    raise("Config not found among these paths: #{paths.inspect}")
end
load(dir, output = $stderr) click to toggle source
# File lib/cide/config_file.rb, line 79
def self.load(dir, output = $stderr)
  file_path = find_config(dir)
  load_file(file_path, output)
end
load_file(file_path, output = $stderr) click to toggle source
# File lib/cide/config_file.rb, line 84
def self.load_file(file_path, output = $stderr)
  obj = new
  loader = ConfigFileLoader.new(obj)
  loader.load YAML.load_file(file_path)

  obj.warnings.each do |warn|
    output.puts "WARN: #{warn}"
  end

  obj.errors.each do |error|
    output.puts "ERROR: #{error}"
  end

  return obj if obj.errors.empty?
  nil
end
new(*) click to toggle source
Calls superclass method
# File lib/cide/config_file.rb, line 69
def initialize(*)
  super
  @warnings = []
  @errors = []
end

Public Instance Methods

to_dockerfile() click to toggle source
# File lib/cide/config_file.rb, line 75
def to_dockerfile
  ERB.new(File.read(DOCKERFILE_TEMPLATE), nil, '<>-').result(binding)
end