libis-workflow 2.0.beta.12 → 2.0.beta.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/lib/libis/workflow/base/workflow.rb +16 -10
- data/lib/libis/workflow/task.rb +54 -19
- data/lib/libis/workflow/version.rb +1 -1
- data/spec/workflow_spec.rb +2 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee7675981468e33b70d8f03bb43ade771225a34b
|
4
|
+
data.tar.gz: 2770f1c82005d427bcc29c8aa08d84f395f971f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 557aa30bcff78d439b02008c86c5a1a4f43264fb23d1405012e0f3430006581c5ee2ce092aa0421fa89357b9ff7576b51cca6788f0fc15d22ca5e99be8f3ab75
|
7
|
+
data.tar.gz: dd1c1fabe78d2ca9a7ad0f89ce6ae0975a478e1383a904119fa6a55fdc2111340f3aa2fbdc9deb56faf43a8d52ac88f9ec18bc61ae6925e17e7f49e7371cb9ee
|
data/.travis.yml
CHANGED
@@ -98,31 +98,37 @@ module Libis
|
|
98
98
|
name = input_def.first.to_sym
|
99
99
|
default = input_def.last[:default]
|
100
100
|
parameter = ::Libis::Tools::Parameter.new name, default
|
101
|
-
input_def.last.each { |k, v| parameter[k.to_sym] = v}
|
102
|
-
hash[
|
101
|
+
input_def.last.each { |k, v| parameter[k.to_sym] = v }
|
102
|
+
hash[name] = parameter
|
103
103
|
hash
|
104
104
|
end
|
105
105
|
rescue
|
106
106
|
{}
|
107
107
|
end
|
108
108
|
|
109
|
-
# @param [Hash]
|
110
|
-
def prepare_input(
|
111
|
-
|
109
|
+
# @param [Hash] options
|
110
|
+
def prepare_input(options)
|
111
|
+
result = {}
|
112
112
|
self.input.each do |key, parameter|
|
113
|
-
|
114
|
-
|
113
|
+
if options.has_key?(key)
|
114
|
+
value = parameter.parse(options[key])
|
115
|
+
elsif !parameter[:default].nil?
|
116
|
+
value = parameter[:default]
|
117
|
+
else
|
118
|
+
next
|
119
|
+
end
|
115
120
|
propagate_to = []
|
116
121
|
propagate_to = parameter[:propagate_to] if parameter[:propagate_to].is_a? Array
|
117
122
|
propagate_to = parameter[:propagate_to].split(/[\s,;]+/) if parameter[:propagate_to].is_a? String
|
123
|
+
result[key] = value if propagate_to.empty?
|
118
124
|
propagate_to.each do |target|
|
119
125
|
task_name, param_name = target.split('#')
|
120
126
|
param_name ||= key
|
121
|
-
|
122
|
-
|
127
|
+
result[task_name] ||= {}
|
128
|
+
result[task_name][param_name.to_sym] = value
|
123
129
|
end
|
124
130
|
end
|
125
|
-
|
131
|
+
result
|
126
132
|
end
|
127
133
|
|
128
134
|
def tasks(parent = nil)
|
data/lib/libis/workflow/task.rb
CHANGED
@@ -28,6 +28,8 @@ module Libis
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def initialize(parent, cfg = {})
|
31
|
+
@subitems_stopper = false
|
32
|
+
@subtasks_stopper = false
|
31
33
|
self.parent = parent
|
32
34
|
self.tasks = []
|
33
35
|
configure cfg
|
@@ -61,12 +63,7 @@ module Libis
|
|
61
63
|
|
62
64
|
self.workitem = item
|
63
65
|
|
64
|
-
|
65
|
-
|
66
|
-
pre_process item
|
67
|
-
i = process_item item
|
68
|
-
item = i if i.is_a? Libis::Workflow::Base::WorkItem
|
69
|
-
post_process item
|
66
|
+
process_item item
|
70
67
|
|
71
68
|
rescue WorkflowError => e
|
72
69
|
error e.message
|
@@ -82,8 +79,6 @@ module Libis
|
|
82
79
|
log_failed item
|
83
80
|
end
|
84
81
|
|
85
|
-
log_done item unless item.failed?
|
86
|
-
|
87
82
|
end
|
88
83
|
|
89
84
|
def names
|
@@ -101,9 +96,9 @@ module Libis
|
|
101
96
|
if o and o.is_a? Hash
|
102
97
|
default_values.each do |name, _|
|
103
98
|
next unless o.key?(name)
|
104
|
-
next
|
105
|
-
|
106
|
-
|
99
|
+
next if o[name].nil?
|
100
|
+
paramdef = get_parameter_definition name
|
101
|
+
value = paramdef.parse(o[name])
|
107
102
|
self.parameter(name, value)
|
108
103
|
end
|
109
104
|
end
|
@@ -115,6 +110,34 @@ module Libis
|
|
115
110
|
|
116
111
|
protected
|
117
112
|
|
113
|
+
def stop_processing_subitems
|
114
|
+
@subitems_stopper = true if parameter(:recursive)
|
115
|
+
end
|
116
|
+
|
117
|
+
def check_processing_subitems
|
118
|
+
if @subitems_stopper
|
119
|
+
@subitems_stopper = false
|
120
|
+
return false
|
121
|
+
end
|
122
|
+
true
|
123
|
+
end
|
124
|
+
|
125
|
+
def stop_processing_subtasks
|
126
|
+
@subtasks_stopper= true
|
127
|
+
end
|
128
|
+
|
129
|
+
def check_processing_subtasks
|
130
|
+
if @subtasks_stopper
|
131
|
+
@subtasks_stopper = false
|
132
|
+
return false
|
133
|
+
end
|
134
|
+
true
|
135
|
+
end
|
136
|
+
|
137
|
+
def skip_processing_item
|
138
|
+
@item_skipper = true
|
139
|
+
end
|
140
|
+
|
118
141
|
def log_started(item)
|
119
142
|
item.status = to_status :started
|
120
143
|
end
|
@@ -129,9 +152,18 @@ module Libis
|
|
129
152
|
end
|
130
153
|
|
131
154
|
def process_item(item)
|
132
|
-
|
133
|
-
|
134
|
-
|
155
|
+
@item_skipper = false
|
156
|
+
pre_process(item)
|
157
|
+
unless @item_skipper
|
158
|
+
log_started item
|
159
|
+
process item
|
160
|
+
end
|
161
|
+
run_subitems(item) if parameter(:recursive)
|
162
|
+
unless @item_skipper
|
163
|
+
run_subtasks item
|
164
|
+
log_done item unless item.failed?
|
165
|
+
end
|
166
|
+
post_process item
|
135
167
|
end
|
136
168
|
|
137
169
|
def process(item)
|
@@ -140,6 +172,7 @@ module Libis
|
|
140
172
|
end
|
141
173
|
|
142
174
|
def pre_process(_)
|
175
|
+
true
|
143
176
|
# optional implementation
|
144
177
|
end
|
145
178
|
|
@@ -168,6 +201,7 @@ module Libis
|
|
168
201
|
end
|
169
202
|
|
170
203
|
def run_subitems(parent_item)
|
204
|
+
return unless check_processing_subitems
|
171
205
|
items = subitems parent_item
|
172
206
|
failed = passed = 0
|
173
207
|
items.each_with_index do |item, i|
|
@@ -195,6 +229,7 @@ module Libis
|
|
195
229
|
end
|
196
230
|
|
197
231
|
def run_subtasks(item)
|
232
|
+
return unless check_processing_subtasks
|
198
233
|
tasks = subtasks item
|
199
234
|
tasks.each_with_index do |task, i|
|
200
235
|
debug 'Running subtask (%d/%d): %s', item, i+1, tasks.count, task.name
|
@@ -211,11 +246,11 @@ module Libis
|
|
211
246
|
|
212
247
|
def configure(cfg)
|
213
248
|
self.name = cfg[:name] || (cfg[:class] || self.class).to_s.split('::').last
|
214
|
-
|
215
|
-
cfg[:options]
|
216
|
-
).
|
217
|
-
|
218
|
-
|
249
|
+
(cfg[:options] || {}).merge(
|
250
|
+
cfg.reject { |k, _| [:options, :name, :class].include? k.to_sym }
|
251
|
+
).symbolize_keys.each do |k,v|
|
252
|
+
self.parameter(k,v)
|
253
|
+
end
|
219
254
|
end
|
220
255
|
|
221
256
|
def to_status(text)
|
@@ -2,6 +2,6 @@
|
|
2
2
|
|
3
3
|
module Libis
|
4
4
|
module Workflow
|
5
|
-
VERSION = '2.0.beta.
|
5
|
+
VERSION = '2.0.beta.13' unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
|
6
6
|
end
|
7
7
|
end
|
data/spec/workflow_spec.rb
CHANGED
@@ -65,7 +65,8 @@ describe 'TestWorkflow' do
|
|
65
65
|
|
66
66
|
# noinspection RubyResolve
|
67
67
|
it 'should camelize the workitem name' do
|
68
|
-
|
68
|
+
puts run.options
|
69
|
+
expect(run.options['CollectFiles'][:location]).to eq dirname
|
69
70
|
expect(run.items.count).to eq 1
|
70
71
|
expect(run.items.first.class).to eq TestDirItem
|
71
72
|
expect(run.items.first.count).to eq 3
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libis-workflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.beta.
|
4
|
+
version: 2.0.beta.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kris Dekeyser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
175
|
version: 1.3.1
|
176
176
|
requirements: []
|
177
177
|
rubyforge_project:
|
178
|
-
rubygems_version: 2.
|
178
|
+
rubygems_version: 2.2.2
|
179
179
|
signing_key:
|
180
180
|
specification_version: 4
|
181
181
|
summary: LIBIS Workflow framework.
|