workflow 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +8 -1
- data/Gemfile +0 -1
- data/README.markdown +73 -27
- data/Rakefile +3 -9
- data/gemfiles/Gemfile.rails-2.3.x +1 -0
- data/gemfiles/Gemfile.rails-3.x +11 -0
- data/gemfiles/Gemfile.rails-edge +12 -0
- data/lib/workflow.rb +52 -227
- data/lib/workflow/adapters/active_record.rb +66 -0
- data/lib/workflow/adapters/remodel.rb +15 -0
- data/lib/workflow/draw.rb +79 -0
- data/lib/workflow/errors.rb +18 -0
- data/lib/workflow/event.rb +18 -0
- data/lib/workflow/specification.rb +64 -0
- data/lib/workflow/state.rb +44 -0
- data/lib/workflow/version.rb +1 -1
- data/orders_workflow.png +0 -0
- data/test/active_record_scopes_test.rb +49 -0
- data/test/advanced_examples_test.rb +21 -0
- data/test/attr_protected_test.rb +3 -0
- data/test/inheritance_test.rb +60 -0
- data/test/main_test.rb +7 -6
- data/test/new_versions/compare_states_test.rb +2 -1
- data/workflow.gemspec +1 -0
- metadata +86 -46
- data/workflow.rb +0 -1
data/test/main_test.rb
CHANGED
@@ -14,7 +14,7 @@ class Order < ActiveRecord::Base
|
|
14
14
|
include Workflow
|
15
15
|
workflow do
|
16
16
|
state :submitted do
|
17
|
-
event :accept, :transitions_to => :accepted, :meta => {:
|
17
|
+
event :accept, :transitions_to => :accepted, :meta => {:weight => 8} do |reviewer, args|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
state :accepted do
|
@@ -31,7 +31,7 @@ class LegacyOrder < ActiveRecord::Base
|
|
31
31
|
|
32
32
|
workflow do
|
33
33
|
state :submitted do
|
34
|
-
event :accept, :transitions_to => :accepted, :meta => {:
|
34
|
+
event :accept, :transitions_to => :accepted, :meta => {:weight => 8} do |reviewer, args|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
state :accepted do
|
@@ -438,8 +438,9 @@ class MainTest < ActiveRecordTestCase
|
|
438
438
|
test 'diagram generation' do
|
439
439
|
begin
|
440
440
|
$stdout = StringIO.new('', 'w')
|
441
|
-
|
442
|
-
|
441
|
+
require 'workflow/draw'
|
442
|
+
Workflow::Draw::workflow_diagram(Order, :path => '/tmp')
|
443
|
+
assert_match(/run the following/, $stdout.string,
|
443
444
|
'PDF should be generate and a hint be given to the user.')
|
444
445
|
ensure
|
445
446
|
$stdout = STDOUT
|
@@ -519,7 +520,7 @@ class MainTest < ActiveRecordTestCase
|
|
519
520
|
test 'workflow graph generation' do
|
520
521
|
Dir.chdir('/tmp') do
|
521
522
|
capture_streams do
|
522
|
-
Workflow::
|
523
|
+
Workflow::Draw::workflow_diagram(Order, :path => '/tmp')
|
523
524
|
end
|
524
525
|
end
|
525
526
|
end
|
@@ -527,7 +528,7 @@ class MainTest < ActiveRecordTestCase
|
|
527
528
|
test 'workflow graph generation in a path with spaces' do
|
528
529
|
`mkdir -p '/tmp/Workflow test'`
|
529
530
|
capture_streams do
|
530
|
-
Workflow::
|
531
|
+
Workflow::Draw::workflow_diagram(Order, :path => '/tmp/Workflow test')
|
531
532
|
end
|
532
533
|
end
|
533
534
|
|
@@ -5,7 +5,7 @@ class ComparableStatesOrder
|
|
5
5
|
include Workflow
|
6
6
|
workflow do
|
7
7
|
state :submitted do
|
8
|
-
event :accept, :transitions_to => :accepted, :meta => {:
|
8
|
+
event :accept, :transitions_to => :accepted, :meta => {:weight => 8} do |reviewer, args|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
state :accepted do
|
@@ -21,6 +21,7 @@ class CompareStatesTest < Test::Unit::TestCase
|
|
21
21
|
o = ComparableStatesOrder.new
|
22
22
|
o.accept!
|
23
23
|
assert_equal :accepted, o.current_state.name
|
24
|
+
assert o.current_state == :accepted
|
24
25
|
assert o.current_state < :shipped
|
25
26
|
assert o.current_state > :submitted
|
26
27
|
assert_raise ArgumentError do
|
data/workflow.gemspec
CHANGED
metadata
CHANGED
@@ -1,88 +1,122 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: workflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Vladimir Dobriakov
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-01-14 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rdoc
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '3.12'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.12'
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: bundler
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - '>='
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: 1.0.0
|
33
34
|
type: :development
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.0.0
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: activerecord
|
38
|
-
requirement:
|
39
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
40
44
|
requirements:
|
41
|
-
- -
|
45
|
+
- - '>='
|
42
46
|
- !ruby/object:Gem::Version
|
43
47
|
version: '0'
|
44
48
|
type: :development
|
45
49
|
prerelease: false
|
46
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
47
55
|
- !ruby/object:Gem::Dependency
|
48
56
|
name: sqlite3
|
49
|
-
requirement:
|
50
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - '>='
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '0'
|
55
62
|
type: :development
|
56
63
|
prerelease: false
|
57
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: mocha
|
60
|
-
requirement:
|
61
|
-
none: false
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
62
72
|
requirements:
|
63
|
-
- -
|
73
|
+
- - '>='
|
64
74
|
- !ruby/object:Gem::Version
|
65
75
|
version: '0'
|
66
76
|
type: :development
|
67
77
|
prerelease: false
|
68
|
-
version_requirements:
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rake
|
71
|
-
requirement:
|
72
|
-
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
93
|
requirements:
|
74
|
-
- -
|
94
|
+
- - '>='
|
75
95
|
- !ruby/object:Gem::Version
|
76
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: ruby-graphviz
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.0'
|
77
104
|
type: :development
|
78
105
|
prerelease: false
|
79
|
-
version_requirements:
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.0'
|
111
|
+
description: |2
|
112
|
+
Workflow is a finite-state-machine-inspired API for modeling and interacting
|
113
|
+
with what we tend to refer to as 'workflow'.
|
114
|
+
|
115
|
+
* nice DSL to describe your states, events and transitions
|
116
|
+
* robust integration with ActiveRecord and non relational data stores
|
117
|
+
* various hooks for single transitions, entering state etc.
|
118
|
+
* convenient access to the workflow specification: list states, possible events
|
119
|
+
for particular state
|
86
120
|
email:
|
87
121
|
- vladimir@geekq.net
|
88
122
|
executables: []
|
@@ -97,13 +131,25 @@ files:
|
|
97
131
|
- README.markdown
|
98
132
|
- Rakefile
|
99
133
|
- gemfiles/Gemfile.rails-2.3.x
|
134
|
+
- gemfiles/Gemfile.rails-3.x
|
135
|
+
- gemfiles/Gemfile.rails-edge
|
100
136
|
- lib/workflow.rb
|
137
|
+
- lib/workflow/adapters/active_record.rb
|
138
|
+
- lib/workflow/adapters/remodel.rb
|
139
|
+
- lib/workflow/draw.rb
|
140
|
+
- lib/workflow/errors.rb
|
141
|
+
- lib/workflow/event.rb
|
142
|
+
- lib/workflow/specification.rb
|
143
|
+
- lib/workflow/state.rb
|
101
144
|
- lib/workflow/version.rb
|
145
|
+
- orders_workflow.png
|
146
|
+
- test/active_record_scopes_test.rb
|
102
147
|
- test/advanced_examples_test.rb
|
103
148
|
- test/advanced_hooks_and_validation_test.rb
|
104
149
|
- test/attr_protected_test.rb
|
105
150
|
- test/before_transition_test.rb
|
106
151
|
- test/couchtiny_example.rb
|
152
|
+
- test/inheritance_test.rb
|
107
153
|
- test/main_test.rb
|
108
154
|
- test/multiple_workflows_test.rb
|
109
155
|
- test/new_versions/compare_states_test.rb
|
@@ -113,43 +159,37 @@ files:
|
|
113
159
|
- test/test_helper.rb
|
114
160
|
- test/without_active_record_test.rb
|
115
161
|
- workflow.gemspec
|
116
|
-
- workflow.rb
|
117
162
|
homepage: http://www.geekq.net/workflow/
|
118
163
|
licenses: []
|
164
|
+
metadata: {}
|
119
165
|
post_install_message:
|
120
166
|
rdoc_options: []
|
121
167
|
require_paths:
|
122
168
|
- lib
|
123
169
|
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
-
none: false
|
125
170
|
requirements:
|
126
|
-
- -
|
171
|
+
- - '>='
|
127
172
|
- !ruby/object:Gem::Version
|
128
173
|
version: '0'
|
129
|
-
segments:
|
130
|
-
- 0
|
131
|
-
hash: 666989584691565007
|
132
174
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
-
none: false
|
134
175
|
requirements:
|
135
|
-
- -
|
176
|
+
- - '>='
|
136
177
|
- !ruby/object:Gem::Version
|
137
178
|
version: '0'
|
138
|
-
segments:
|
139
|
-
- 0
|
140
|
-
hash: 666989584691565007
|
141
179
|
requirements: []
|
142
180
|
rubyforge_project:
|
143
|
-
rubygems_version:
|
181
|
+
rubygems_version: 2.0.0
|
144
182
|
signing_key:
|
145
|
-
specification_version:
|
183
|
+
specification_version: 4
|
146
184
|
summary: A replacement for acts_as_state_machine.
|
147
185
|
test_files:
|
186
|
+
- test/active_record_scopes_test.rb
|
148
187
|
- test/advanced_examples_test.rb
|
149
188
|
- test/advanced_hooks_and_validation_test.rb
|
150
189
|
- test/attr_protected_test.rb
|
151
190
|
- test/before_transition_test.rb
|
152
191
|
- test/couchtiny_example.rb
|
192
|
+
- test/inheritance_test.rb
|
153
193
|
- test/main_test.rb
|
154
194
|
- test/multiple_workflows_test.rb
|
155
195
|
- test/new_versions/compare_states_test.rb
|
data/workflow.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Dir["#{File.dirname(__FILE__)}/lib/*.rb"].each { |rb| require rb }
|