bumbleworks 0.0.67 → 0.0.68
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/bumbleworks/task/finder.rb +21 -10
- data/lib/bumbleworks/version.rb +1 -1
- data/spec/lib/bumbleworks/task/finder_spec.rb +36 -6
- metadata +3 -3
@@ -40,16 +40,20 @@ module Bumbleworks
|
|
40
40
|
|
41
41
|
def where(filters, group_type = nil)
|
42
42
|
group_type = :all unless group_type == :any
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
if group_type != @join
|
44
|
+
finder = self.class.new(@task_class)
|
45
|
+
finder.send(:"where_#{group_type}")
|
46
|
+
else
|
47
|
+
finder = self
|
48
|
+
end
|
49
|
+
finder = filters.inject(finder) { |query_target, (key, args)|
|
46
50
|
if method = WhereKeyToMethodMap[key]
|
47
|
-
|
51
|
+
query_target.send(method, args)
|
48
52
|
else
|
49
|
-
|
53
|
+
query_target.with_fields(key => args)
|
50
54
|
end
|
51
55
|
}
|
52
|
-
add_subfinder
|
56
|
+
finder == self ? self : add_subfinder(finder)
|
53
57
|
end
|
54
58
|
|
55
59
|
def available(check = true)
|
@@ -164,12 +168,13 @@ module Bumbleworks
|
|
164
168
|
def each
|
165
169
|
return to_enum(:each) unless block_given?
|
166
170
|
return if @wfids == []
|
171
|
+
only_workitem_queries = @queries.all? { |q| q.is_a? WorkitemQuery }
|
167
172
|
workitems = raw_workitems(@wfids)
|
168
173
|
@orderers.each do |order_proc|
|
169
174
|
workitems.sort! &order_proc
|
170
175
|
end
|
171
176
|
workitems.each { |wi|
|
172
|
-
if task = filtered_task_from_raw_workitem(wi)
|
177
|
+
if task = filtered_task_from_raw_workitem(wi, only_workitem_queries)
|
173
178
|
yield task
|
174
179
|
end
|
175
180
|
}
|
@@ -204,9 +209,15 @@ module Bumbleworks
|
|
204
209
|
self
|
205
210
|
end
|
206
211
|
|
207
|
-
def filtered_task_from_raw_workitem(workitem)
|
208
|
-
|
209
|
-
|
212
|
+
def filtered_task_from_raw_workitem(workitem, only_workitem_queries = false)
|
213
|
+
if only_workitem_queries
|
214
|
+
if check_queries(workitem, nil)
|
215
|
+
task = from_workitem(::Ruote::Workitem.new(workitem))
|
216
|
+
end
|
217
|
+
else
|
218
|
+
task = from_workitem(::Ruote::Workitem.new(workitem))
|
219
|
+
task if check_queries(workitem, task)
|
220
|
+
end
|
210
221
|
end
|
211
222
|
|
212
223
|
def grouped_queries(group_type)
|
data/lib/bumbleworks/version.rb
CHANGED
@@ -123,11 +123,11 @@ describe Bumbleworks::Task::Finder do
|
|
123
123
|
end
|
124
124
|
|
125
125
|
describe '#where' do
|
126
|
-
it 'creates a new finder and adds it to queries' do
|
127
|
-
parent = described_class.new(:
|
126
|
+
it 'creates a new finder and adds it to queries, when join type mismatch' do
|
127
|
+
parent = described_class.new(:dummy_task_class).where_all
|
128
128
|
child = described_class.new
|
129
|
-
described_class.stub(:new).with(:
|
130
|
-
child.should_receive(:
|
129
|
+
described_class.stub(:new).with(:dummy_task_class).and_return(child)
|
130
|
+
child.should_receive(:where_any)
|
131
131
|
child.should_receive(:available).and_return(child)
|
132
132
|
child.should_receive(:unavailable).and_return(child)
|
133
133
|
child.should_receive(:by_nickname).with(:nicholas).and_return(child)
|
@@ -140,7 +140,7 @@ describe Bumbleworks::Task::Finder do
|
|
140
140
|
child.should_receive(:completable).with(true).and_return(child)
|
141
141
|
child.should_receive(:with_fields).with(:horse => :giant_pony).and_return(child)
|
142
142
|
child.should_receive(:with_fields).with(:pie => :silly_cake).and_return(child)
|
143
|
-
parent.should_receive(:add_subfinder).with(child)
|
143
|
+
parent.should_receive(:add_subfinder).with(child).and_return(parent)
|
144
144
|
parent.where({
|
145
145
|
:available => true,
|
146
146
|
:unavailable => true,
|
@@ -154,7 +154,37 @@ describe Bumbleworks::Task::Finder do
|
|
154
154
|
:completable => true,
|
155
155
|
:horse => :giant_pony,
|
156
156
|
:pie => :silly_cake
|
157
|
-
})
|
157
|
+
}, :any).should == parent
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'adds queries to current finder, when join type matches' do
|
161
|
+
subject.should_receive(:available).and_return(subject)
|
162
|
+
subject.should_receive(:unavailable).and_return(subject)
|
163
|
+
subject.should_receive(:by_nickname).with(:nicholas).and_return(subject)
|
164
|
+
subject.should_receive(:for_roles).with([:dinner, :barca]).and_return(subject)
|
165
|
+
subject.should_receive(:unclaimed).and_return(subject)
|
166
|
+
subject.should_receive(:claimed).and_return(subject)
|
167
|
+
subject.should_receive(:for_claimant).with(:dr_clam).and_return(subject)
|
168
|
+
subject.should_receive(:for_entity).with(:a_luffly_pirate).and_return(subject)
|
169
|
+
subject.should_receive(:for_processes).with([:jasmine, :mulan]).and_return(subject)
|
170
|
+
subject.should_receive(:completable).with(true).and_return(subject)
|
171
|
+
subject.should_receive(:with_fields).with(:horse => :giant_pony).and_return(subject)
|
172
|
+
subject.should_receive(:with_fields).with(:pie => :silly_cake).and_return(subject)
|
173
|
+
subject.should_receive(:add_subfinder).never
|
174
|
+
subject.where({
|
175
|
+
:available => true,
|
176
|
+
:unavailable => true,
|
177
|
+
:nickname => :nicholas,
|
178
|
+
:roles => [:dinner, :barca],
|
179
|
+
:unclaimed => true,
|
180
|
+
:claimed => true,
|
181
|
+
:claimant => :dr_clam,
|
182
|
+
:entity => :a_luffly_pirate,
|
183
|
+
:processes => [:jasmine, :mulan],
|
184
|
+
:completable => true,
|
185
|
+
:horse => :giant_pony,
|
186
|
+
:pie => :silly_cake
|
187
|
+
}).should == subject
|
158
188
|
end
|
159
189
|
end
|
160
190
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bumbleworks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.68
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -263,7 +263,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
263
263
|
version: '0'
|
264
264
|
segments:
|
265
265
|
- 0
|
266
|
-
hash: -
|
266
|
+
hash: -2462957176367107392
|
267
267
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
268
268
|
none: false
|
269
269
|
requirements:
|
@@ -272,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
272
272
|
version: '0'
|
273
273
|
segments:
|
274
274
|
- 0
|
275
|
-
hash: -
|
275
|
+
hash: -2462957176367107392
|
276
276
|
requirements: []
|
277
277
|
rubyforge_project:
|
278
278
|
rubygems_version: 1.8.23
|