task-orchestrator 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
data/examples/loops ADDED
@@ -0,0 +1,11 @@
1
+ orchestrator:
2
+ statedir: states
3
+ loop:
4
+ description: loop test
5
+ save: true
6
+ steps:
7
+ - type: sequential
8
+ loop: [1,2,3,4,5,zopa]
9
+ scripts:
10
+ - command: "echo :::LOOP:::"
11
+ - command: sleep 0.1
@@ -135,6 +135,9 @@ module Orchestrator
135
135
  invalid("interpolation type is not valid in this context - :::#{match}:::") if match !~ pattern and match =~ /^(ENV|ARG|EXEC)\./
136
136
 
137
137
  case match
138
+ when /^LOOP$/
139
+ invalid("command interpolation failed not loop type step") unless @loop_param
140
+ @loop_param
138
141
  when /^ENV\./
139
142
  env = match["ENV.".length..-1]
140
143
  invalid("command interpolation failed no such env variable - #{env}") if !ENV[env] and !@defaults[:envs].instance_variable_defined?("@#{env}")
@@ -212,10 +215,25 @@ module Orchestrator
212
215
  invalid("task step has no type") unless step.has_key?('type') && step['type'].is_a?(String)
213
216
  invalid("task step type #{step['type']} is invalid") unless [:parallel,:sequential].find_index(step['type'].to_sym)
214
217
  invalid("task step scripts is missing or invalid") unless step.has_key?('scripts') && step['scripts'].is_a?(Array)
215
- step['failure_handler'] = validate_command(step['failure_handler'], 'task failure handler') if step.has_key?('failure_handler')
216
- step['scripts'].each_index do |index|
217
- step['scripts'][index] = validate_command(step['scripts'][index], 'task step script')
218
+ if step.has_key?('loop')
219
+ invalid("task step loop is not array") unless step['loop'].is_a?(Array)
220
+ scripts = []
221
+ step['loop'].each do |item|
222
+ @loop_param = item
223
+ step['scripts'].each_index do |index|
224
+ script = Marshal.load(Marshal.dump(step['scripts'][index]))
225
+ scripts << validate_command(script, 'task step looped script')
226
+ end
227
+ @loop_param = nil
228
+ end
229
+ step['scripts'] = scripts
230
+ step.delete('loop')
231
+ else
232
+ step['scripts'].each_index do |index|
233
+ step['scripts'][index] = validate_command(step['scripts'][index], 'task step script')
234
+ end
218
235
  end
236
+ step['failure_handler'] = validate_command(step['failure_handler'], 'task failure handler') if step.has_key?('failure_handler')
219
237
  end
220
238
  end
221
239
 
@@ -1,3 +1,3 @@
1
1
  module Orchestrator
2
- VERSION ||= '0.0.15'
2
+ VERSION ||= '0.0.16'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: task-orchestrator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-24 00:00:00.000000000 Z
12
+ date: 2014-01-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pony
@@ -94,6 +94,7 @@ files:
94
94
  - examples/dependencies
95
95
  - examples/sequential
96
96
  - examples/failure_handler
97
+ - examples/loops
97
98
  - examples/parallel
98
99
  - examples/flock
99
100
  - examples/multistep