Class: CIDE::Build::Config
- Inherits:
-
Object
- Object
- CIDE::Build::Config
- Includes:
- NiceInspect
- Defined in:
- lib/cide/build/config.rb
Defined Under Namespace
Modules: NiceInspect Classes: FileAdd, Link, Step
Constant Summary collapse
- DOCKERFILE_TEMPLATE =
File.('../../dockerfile_template.erb', __FILE__)
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Class Method Summary collapse
- .find_config(dir) ⇒ Object
- .load(dir = Dir.pwd, output = $stderr) ⇒ Object
- .load_file(file_path, output = $stderr) ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #to_dockerfile ⇒ Object
Methods included from NiceInspect
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
63 64 65 66 67 |
# File 'lib/cide/build/config.rb', line 63 def initialize(*) super @warnings = [] @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
61 62 63 |
# File 'lib/cide/build/config.rb', line 61 def errors @errors end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
61 62 63 |
# File 'lib/cide/build/config.rb', line 61 def warnings @warnings end |
Class Method Details
.find_config(dir) ⇒ Object
95 96 97 98 99 100 |
# File 'lib/cide/build/config.rb', line 95 def self.find_config(dir) paths = CONFIG_FILES.map { |name| File.(name, dir) } paths .find { |path| File.exist?(path) } || fail("Config not found among these paths: #{paths.inspect}") end |
.load(dir = Dir.pwd, output = $stderr) ⇒ Object
73 74 75 76 |
# File 'lib/cide/build/config.rb', line 73 def self.load(dir = Dir.pwd, output = $stderr) file_path = find_config(dir) load_file(file_path, output) end |
.load_file(file_path, output = $stderr) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/cide/build/config.rb', line 78 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
69 70 71 |
# File 'lib/cide/build/config.rb', line 69 def to_dockerfile ERB.new(File.read(DOCKERFILE_TEMPLATE), nil, '<>-').result(binding) end |