Class: Juici::BuildEnvironment

Inherits:
Object
  • Object
show all
Defined in:
lib/juici/build_environment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBuildEnvironment

Returns a new instance of BuildEnvironment.



6
7
8
9
10
11
12
13
# File 'lib/juici/build_environment.rb', line 6

def initialize
  @env = ENV.to_hash.tap do |env|
    BUILD_SENSITIVE_VARIABLES.each do |var|
      env[var] = nil
    end
    env["BUNDLE_CONFIG"] = "/nonexistent"
  end
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



5
6
7
# File 'lib/juici/build_environment.rb', line 5

def env
  @env
end

Instance Method Details

#[](k) ⇒ Object



15
16
17
# File 'lib/juici/build_environment.rb', line 15

def [](k)
  env[k]
end

#load_json!(json) ⇒ Object

XXX This is spectacular. Not in the good way



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/juici/build_environment.rb', line 21

def load_json!(json)
  return true if json == ""
  loaded_json = JSON.load(json)
  if loaded_json.is_a? Hash
    env.merge!(loaded_json)
    return true
  end
  false
rescue JSON::ParserError
  return false
end

#to_hashObject



33
34
35
# File 'lib/juici/build_environment.rb', line 33

def to_hash
  env
end