Class: Construi::Config::Global

Inherits:
Object
  • Object
show all
Includes:
Environment
Defined in:
lib/construi/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Environment

#key?, #parent, #with_parent

Methods included from Files

#files, #files_configured?

Methods included from Image

#build, #image, #image_configured, #image_configured?, #privileged?

Constructor Details

#initialize(yaml) ⇒ Global

Returns a new instance of Global.



79
80
81
# File 'lib/construi/config.rb', line 79

def initialize(yaml)
  @yaml = yaml
end

Instance Attribute Details

#yamlObject (readonly)

Returns the value of attribute yaml.



77
78
79
# File 'lib/construi/config.rb', line 77

def yaml
  @yaml
end

Instance Method Details

#envObject



83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/construi/config.rb', line 83

def env
  return [] if yaml['environment'].nil?

  yaml['environment'].reduce([]) do |acc, e|
    key = e.partition('=').first
    value = e.partition('=').last

    value = ENV[key] if value.empty?

    acc << "#{key}=#{value}" unless value.nil? or value.empty?
    acc
  end
end

#target(target) ⇒ Object



97
98
99
100
101
102
103
# File 'lib/construi/config.rb', line 97

def target(target)
  targets = yaml['targets']

  return nil if targets.nil?

  return Target.new yaml['targets'][target], self
end