bumbleworks 0.0.65 → 0.0.66
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/bumbleworks/task.rb +1 -1
- data/lib/bumbleworks/task/finder.rb +18 -14
- data/lib/bumbleworks/version.rb +1 -1
- data/spec/lib/bumbleworks/task/finder_spec.rb +46 -18
- metadata +4 -4
data/lib/bumbleworks/task.rb
CHANGED
@@ -3,13 +3,13 @@ module Bumbleworks
|
|
3
3
|
class Finder
|
4
4
|
include Enumerable
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
@queries = queries
|
8
|
-
@queries << proc { |wi| wi['fields']['params']['task'] }
|
6
|
+
def initialize(task_class = Bumbleworks::Task)
|
9
7
|
@task_class = task_class
|
8
|
+
@queries = []
|
10
9
|
@task_filters = []
|
11
10
|
@orderers = []
|
12
11
|
@wfids = nil
|
12
|
+
add_query { |wi| wi['fields']['params']['task'] }
|
13
13
|
end
|
14
14
|
|
15
15
|
def where(filters)
|
@@ -43,14 +43,12 @@ module Bumbleworks
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def by_nickname(nickname)
|
46
|
-
|
47
|
-
self
|
46
|
+
add_query { |wi| wi['fields']['params']['task'] == nickname }
|
48
47
|
end
|
49
48
|
|
50
49
|
def for_roles(identifiers)
|
51
50
|
identifiers ||= []
|
52
|
-
|
53
|
-
self
|
51
|
+
add_query { |wi| identifiers.include?(wi['participant_name']) }
|
54
52
|
end
|
55
53
|
|
56
54
|
def for_role(identifier)
|
@@ -58,8 +56,7 @@ module Bumbleworks
|
|
58
56
|
end
|
59
57
|
|
60
58
|
def unclaimed(check = true)
|
61
|
-
|
62
|
-
self
|
59
|
+
add_query { |wi| wi['fields']['params']['claimant'].nil? == check }
|
63
60
|
end
|
64
61
|
|
65
62
|
def claimed(check = true)
|
@@ -67,13 +64,11 @@ module Bumbleworks
|
|
67
64
|
end
|
68
65
|
|
69
66
|
def with_fields(field_hash)
|
70
|
-
|
71
|
-
self
|
67
|
+
add_query { |wi| field_hash.all? { |k, v| wi['fields'][k.to_s] == v } }
|
72
68
|
end
|
73
69
|
|
74
70
|
def for_claimant(token)
|
75
|
-
|
76
|
-
self
|
71
|
+
add_query { |wi| wi['fields']['params']['claimant'] == token }
|
77
72
|
end
|
78
73
|
|
79
74
|
def for_entity(entity)
|
@@ -112,7 +107,16 @@ module Bumbleworks
|
|
112
107
|
end
|
113
108
|
|
114
109
|
def completable(true_or_false = true)
|
115
|
-
|
110
|
+
add_filter { |task| task.completable? == true_or_false }
|
111
|
+
end
|
112
|
+
|
113
|
+
def add_query(&block)
|
114
|
+
@queries << block
|
115
|
+
self
|
116
|
+
end
|
117
|
+
|
118
|
+
def add_filter(&block)
|
119
|
+
@task_filters << block
|
116
120
|
self
|
117
121
|
end
|
118
122
|
|
data/lib/bumbleworks/version.rb
CHANGED
@@ -14,11 +14,41 @@ describe Bumbleworks::Task::Finder do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
describe '#add_query' do
|
18
|
+
it 'adds given block as new raw workitem query' do
|
19
|
+
Bumbleworks.launch!('dog-lifecycle')
|
20
|
+
Bumbleworks.dashboard.wait_for(:cat)
|
21
|
+
finder = subject.add_query { |wi|
|
22
|
+
wi['fields']['params']['task'] != 'pet_dog'
|
23
|
+
}
|
24
|
+
finder.map(&:nickname).should =~ [
|
25
|
+
'eat',
|
26
|
+
'bark',
|
27
|
+
'skip_and_jump'
|
28
|
+
]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#add_filter' do
|
33
|
+
it 'adds given block as new task filter' do
|
34
|
+
Bumbleworks.launch!('dog-lifecycle')
|
35
|
+
Bumbleworks.dashboard.wait_for(:cat)
|
36
|
+
finder = subject.add_filter { |task|
|
37
|
+
task.nickname != 'pet_dog'
|
38
|
+
}
|
39
|
+
finder.map(&:nickname).should =~ [
|
40
|
+
'eat',
|
41
|
+
'bark',
|
42
|
+
'skip_and_jump'
|
43
|
+
]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
17
47
|
describe '#all' do
|
18
48
|
it 'uses Bumbleworks::Task class by default for task generation' do
|
19
49
|
Bumbleworks.launch!('dog-lifecycle')
|
20
50
|
Bumbleworks.dashboard.wait_for(:cat)
|
21
|
-
tasks =
|
51
|
+
tasks = subject.all
|
22
52
|
tasks.should be_all { |t| t.class == Bumbleworks::Task }
|
23
53
|
end
|
24
54
|
|
@@ -26,7 +56,7 @@ describe Bumbleworks::Task::Finder do
|
|
26
56
|
class MyOwnTask < Bumbleworks::Task; end
|
27
57
|
Bumbleworks.launch!('dog-lifecycle')
|
28
58
|
Bumbleworks.dashboard.wait_for(:cat)
|
29
|
-
tasks =
|
59
|
+
tasks = described_class.new(MyOwnTask).all
|
30
60
|
tasks.should be_all { |t| t.class == MyOwnTask }
|
31
61
|
Object.send(:remove_const, :MyOwnTask)
|
32
62
|
end
|
@@ -34,27 +64,25 @@ describe Bumbleworks::Task::Finder do
|
|
34
64
|
|
35
65
|
describe '#available' do
|
36
66
|
it 'adds both unclaimed and completable filters' do
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
query.available
|
67
|
+
subject.should_receive(:unclaimed).and_return(subject)
|
68
|
+
subject.should_receive(:completable).and_return(subject)
|
69
|
+
subject.available
|
41
70
|
end
|
42
71
|
end
|
43
72
|
|
44
73
|
describe '#where' do
|
45
74
|
it 'compiles a finder' do
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
query.where({
|
75
|
+
subject.should_receive(:available).and_return(subject)
|
76
|
+
subject.should_receive(:by_nickname).with(:nicholas).and_return(subject)
|
77
|
+
subject.should_receive(:for_roles).with([:dinner, :barca]).and_return(subject)
|
78
|
+
subject.should_receive(:unclaimed).and_return(subject)
|
79
|
+
subject.should_receive(:claimed).and_return(subject)
|
80
|
+
subject.should_receive(:for_claimant).with(:dr_clam).and_return(subject)
|
81
|
+
subject.should_receive(:for_entity).with(:a_luffly_pirate).and_return(subject)
|
82
|
+
subject.should_receive(:for_processes).with([:jasmine, :mulan]).and_return(subject)
|
83
|
+
subject.should_receive(:completable).with(true).and_return(subject)
|
84
|
+
subject.should_receive(:with_fields).with({ :horse => :giant_pony, :pie => :silly_cake }).and_return(subject)
|
85
|
+
subject.where({
|
58
86
|
:available => true,
|
59
87
|
:nickname => :nicholas,
|
60
88
|
:roles => [:dinner, :barca],
|
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.66
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2014-02-
|
15
|
+
date: 2014-02-12 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: ruote
|
@@ -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: 2932416293581742499
|
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: 2932416293581742499
|
276
276
|
requirements: []
|
277
277
|
rubyforge_project:
|
278
278
|
rubygems_version: 1.8.23
|