Class: WWTD::Run

Inherits:
Object
  • Object
show all
Defined in:
lib/wwtd/run.rb

Constant Summary collapse

SCRIPT_SECTIONS =
["before_install", "install", "before_script", "script", "after_script"]

Instance Method Summary collapse

Constructor Details

#initialize(config, env, lock) ⇒ Run

Returns a new instance of Run.



6
7
8
9
10
# File 'lib/wwtd/run.rb', line 6

def initialize(config, env, lock)
  @config, @env, @lock = config, env, lock
  add_env_from_config
  @switch = build_switch_statement
end

Instance Method Details

#env_and_command_for_section(key) ⇒ Object

internal api



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/wwtd/run.rb', line 26

def env_and_command_for_section(key)
  if command = config[key]
    command = [command] unless Array === command
    command = command.map { |cmd| "#{switch}#{cmd}" }.join(" && ")

    [env, command]
  elsif key == "script"
    command = (wants_bundle? ? "#{switch}bundle exec rake" : "#{switch}rake")
    [env, command]
  end
end

#execute {|state, config| ... } ⇒ Object

Yields:

  • (state, config)


12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/wwtd/run.rb', line 12

def execute
  state = if Ruby.available?(config["rvm"])
    yield(:start, config)
    success? ? :success : :failure
  else
    :missing_ruby_version
  end

  yield(state, config)

  [state, config]
end