Class: WWTD::Run

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

Instance Method Summary collapse

Constructor Details

#initialize(config, env, lock) ⇒ Run

Returns a new instance of Run.



3
4
5
6
7
# File 'lib/wwtd/run.rb', line 3

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_commandObject

internal api



23
24
25
26
27
28
29
30
# File 'lib/wwtd/run.rb', line 23

def env_and_command
  default_command = (wants_bundle? ? "bundle exec rake" : "rake")
  command = config["script"] || default_command
  command = command.join(" && ") if Array === command
  command = "#{switch}#{command}"

  [env, command]
end

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

Yields:

  • (state, config)


9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/wwtd/run.rb', line 9

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

  yield(state, config)

  [state, config]
end