Class: CIDE::Build::Config

Inherits:
Object
  • Object
show all
Includes:
NiceInspect
Defined in:
lib/cide/build/config.rb

Defined Under Namespace

Modules: NiceInspect Classes: Link, Step

Constant Summary collapse

DOCKERFILE_TEMPLATE =
File.expand_path('../../dockerfile_template.erb', __FILE__)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from NiceInspect

#inspect

Constructor Details

#initialize ⇒ Config

Returns a new instance of Config.



56
57
58
59
60
# File 'lib/cide/build/config.rb', line 56

def initialize(*)
  super
  @warnings = []
  @errors = []
end

Instance Attribute Details

#errors ⇒ Object (readonly)

Returns the value of attribute errors.



54
55
56
# File 'lib/cide/build/config.rb', line 54

def errors
  @errors
end

#warnings ⇒ Object (readonly)

Returns the value of attribute warnings.



54
55
56
# File 'lib/cide/build/config.rb', line 54

def warnings
  @warnings
end

Class Method Details

.load_file(file_path, output = $stderr) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/cide/build/config.rb', line 66

def self.load_file(file_path, output = $stderr)
  obj = new
  loader = ConfigLoader.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

Instance Method Details

#to_dockerfile ⇒ Object



62
63
64
# File 'lib/cide/build/config.rb', line 62

def to_dockerfile
  ERB.new(File.read(DOCKERFILE_TEMPLATE), nil, '<>-').result(binding)
end