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

#parent, #with_parent

Methods included from Files

#files, #files_configured?

Methods included from Image

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

Constructor Details

#initialize(yaml) ⇒ Global

Returns a new instance of Global.



72
73
74
# File 'lib/construi/config.rb', line 72

def initialize(yaml)
  @yaml = yaml
end

Instance Attribute Details

#yamlObject (readonly)

Returns the value of attribute yaml.



70
71
72
# File 'lib/construi/config.rb', line 70

def yaml
  @yaml
end

Instance Method Details

#envObject



76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/construi/config.rb', line 76

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



90
91
92
93
94
95
96
# File 'lib/construi/config.rb', line 90

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

  return nil if targets.nil?

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