Class: CIDE::Build::ConfigLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/cide/build/config_loader.rb

Defined Under Namespace

Classes: Path

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ ConfigLoader

Returns a new instance of ConfigLoader.



17
18
19
# File 'lib/cide/build/config_loader.rb', line 17

def initialize(config)
  @config = config
end

Instance Method Details

#load(data) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/cide/build/config_loader.rb', line 21

def load(data)
  data.each_pair do |key, value|
    key = key.to_s
    path = Path.new(key)
    case key
    when 'from', 'image' then
      wanted_key(path, 'from', key)
      @config.from = expect_string(path, value)
    when 'as_root' then
      @config.as_root = expect_array(path, value)
    when 'use_ssh' then
      @config.use_ssh = expect_boolean(path, value)
    when 'before' then
      @config.before = maybe_step(path, value)
    when 'forward_env' then
      @config.forward_env = expect_array(path, value)
    when 'export_dir' then
      @config.export_dir = maybe_string(path, value)
    when 'link', 'links' then
      @config.links = expect_links(path, value)
    when 'run', 'command' then
      wanted_key(path, 'run', key)
      @config.run = expect_string(path, value)
    else
      unknown_key(path)
    end
  end
  @config
end