Class: Potemkin::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/potemkin/builder.rb

Direct Known Subclasses

AndroidBuilder, IosBuilder

Instance Method Summary collapse

Instance Method Details

#buildObject

Will build the actual APK



10
11
12
13
# File 'lib/potemkin/builder.rb', line 10

def build
  logger.describe "creating build"
  with_env_vars(env_vars) { Potemkin.run build_command }
end

#cleanObject



15
16
17
18
# File 'lib/potemkin/builder.rb', line 15

def clean
  logger.describe "cleaning build"
  with_env_vars(env_vars) { Potemkin.run clean_command }
end

#configObject

Returns the config, mainly here to mock in tests



39
40
41
# File 'lib/potemkin/builder.rb', line 39

def config
  Potemkin.config
end

#env_varsObject

No environment variables by default



5
6
7
# File 'lib/potemkin/builder.rb', line 5

def env_vars
  {}
end

#loggerObject

Returns the logger, mainly here to mock in tests



44
45
46
# File 'lib/potemkin/builder.rb', line 44

def logger
  Potemkin.logger
end

#with_env_vars(env_vars) ⇒ Object

Takes a hash and a block, wrapping the block with the env variables found in the hash.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/potemkin/builder.rb', line 22

def with_env_vars(env_vars)
  old_values = {}
  env_vars.each do |key,new_value|
    old_values[key] = ENV[key]
    ENV[key] = new_value
  end

  return_value = yield

  env_vars.each_key do |key|
    ENV[key] = old_values[key]
  end

  return_value
end