Class: WWTD::Run
- Inherits:
-
Object
- Object
- WWTD::Run
- Defined in:
- lib/wwtd/run.rb
Constant Summary collapse
- SCRIPT_SECTIONS =
["before_install", "install", "before_script", "script", "after_script"]
Instance Method Summary collapse
-
#env_and_command_for_section(key) ⇒ Object
internal api.
- #execute {|state, config| ... } ⇒ Object
-
#initialize(config, env, lock) ⇒ Run
constructor
A new instance of Run.
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
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 |