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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3baa19f0fbc05d8254835124a68bf02dff63952d
4
- data.tar.gz: 9a6f33b1e6de7ee1d699aaaca71e80a2194b1d9b
3
+ metadata.gz: ee7675981468e33b70d8f03bb43ade771225a34b
4
+ data.tar.gz: 2770f1c82005d427bcc29c8aa08d84f395f971f8
5
5
  SHA512:
6
- metadata.gz: dd107fb0efd65099dda2c0215d93ad75fde65c0a2e3271f87ce505157ea1b1f321874d426f63a315214e3c09ba3ca3dc3d2f7d620edcdc02c16292912b38df41
7
- data.tar.gz: 61199cfae002d01666ae76d76c2e5acdca3c837d99c59f57da0a972d9c21bdb011e59a89ebda3373f9b6387518cc0673f5d9282bf2516a72f7da5983cad36804
6
+ metadata.gz: 557aa30bcff78d439b02008c86c5a1a4f43264fb23d1405012e0f3430006581c5ee2ce092aa0421fa89357b9ff7576b51cca6788f0fc15d22ca5e99be8f3ab75
7
+ data.tar.gz: dd1c1fabe78d2ca9a7ad0f89ce6ae0975a478e1383a904119fa6a55fdc2111340f3aa2fbdc9deb56faf43a8d52ac88f9ec18bc61ae6925e17e7f49e7371cb9ee
data/.travis.yml CHANGED
@@ -25,6 +25,8 @@ matrix:
25
25
  jdk: oraclejdk7
26
26
  - rvm: ruby-head
27
27
  jdk: oraclejdk8
28
+ allow_failures:
29
+ - rvm: ruby-head
28
30
  branches:
29
31
  only:
30
32
  - master
@@ -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[input_def.first.to_sym] = parameter
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] opts
110
- def prepare_input(opts)
111
- options = opts.dup
109
+ # @param [Hash] options
110
+ def prepare_input(options)
111
+ result = {}
112
112
  self.input.each do |key, parameter|
113
- options[key] = parameter[:default] unless options.has_key?(key)
114
- options[key] = parameter.parse(options[key])
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
- options[task_name] ||= {}
122
- options[task_name][param_name.to_sym] = options[key]
127
+ result[task_name] ||= {}
128
+ result[task_name][param_name.to_sym] = value
123
129
  end
124
130
  end
125
- options
131
+ result
126
132
  end
127
133
 
128
134
  def tasks(parent = nil)
@@ -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
- log_started item
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 unless o[name]
105
- parameter = get_parameter_definition name
106
- next unless (value = parameter.parse(o[name]))
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
- process item
133
- run_subitems(workitem) if parameter(:recursive)
134
- run_subtasks workitem
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
- default_values.merge(
215
- cfg[:options] || {}
216
- ).merge(
217
- cfg.reject { |k, _| [:options].include? k.to_sym }
218
- ).symbolize_keys!.each { |k,v| self[k] = v }
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.12' unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
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
@@ -65,7 +65,8 @@ describe 'TestWorkflow' do
65
65
 
66
66
  # noinspection RubyResolve
67
67
  it 'should camelize the workitem name' do
68
- expect(run.options[:dirname]).to eq dirname
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.12
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-09 00:00:00.000000000 Z
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.5.0
178
+ rubygems_version: 2.2.2
179
179
  signing_key:
180
180
  specification_version: 4
181
181
  summary: LIBIS Workflow framework.