aasm 4.0.8 → 4.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +7 -2
- data/CHANGELOG.md +43 -2
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +6 -3
- data/LICENSE +1 -1
- data/PLANNED_CHANGES.md +8 -4
- data/README.md +171 -14
- data/aasm.gemspec +1 -5
- data/gemfiles/rails_3.2.gemfile +3 -2
- data/gemfiles/rails_4.0.gemfile +2 -6
- data/gemfiles/rails_4.0_mongo_mapper.gemfile +14 -0
- data/gemfiles/rails_4.1.gemfile +2 -6
- data/gemfiles/rails_4.1_mongo_mapper.gemfile +14 -0
- data/gemfiles/rails_4.2.gemfile +1 -5
- data/gemfiles/rails_4.2_mongo_mapper.gemfile +14 -0
- data/gemfiles/rails_4.2_mongoid_5.gemfile +12 -0
- data/lib/aasm/aasm.rb +69 -36
- data/lib/aasm/base.rb +51 -21
- data/lib/aasm/core/event.rb +7 -6
- data/lib/aasm/core/state.rb +11 -8
- data/lib/aasm/core/transition.rb +7 -5
- data/lib/aasm/errors.rb +15 -1
- data/lib/aasm/instance_base.rb +17 -13
- data/lib/aasm/localizer.rb +1 -1
- data/lib/aasm/persistence/active_record_persistence.rb +63 -73
- data/lib/aasm/persistence/base.rb +55 -20
- data/lib/aasm/persistence/mongo_mapper_persistence.rb +157 -0
- data/lib/aasm/persistence/mongoid_persistence.rb +16 -41
- data/lib/aasm/persistence/plain_persistence.rb +8 -7
- data/lib/aasm/persistence/sequel_persistence.rb +12 -9
- data/lib/aasm/persistence.rb +2 -0
- data/lib/aasm/rspec/allow_event.rb +22 -0
- data/lib/aasm/rspec/allow_transition_to.rb +22 -0
- data/lib/aasm/rspec/have_state.rb +22 -0
- data/lib/aasm/rspec/transition_from.rb +32 -0
- data/lib/aasm/rspec.rb +5 -0
- data/lib/aasm/state_machine.rb +20 -6
- data/lib/aasm/version.rb +1 -1
- data/spec/database.rb +27 -1
- data/spec/models/active_record/basic_active_record_two_state_machines_example.rb +25 -0
- data/spec/models/active_record/complex_active_record_example.rb +33 -0
- data/spec/models/active_record/derivate_new_dsl.rb +7 -0
- data/spec/models/active_record/false_state.rb +35 -0
- data/spec/models/active_record/gate.rb +39 -0
- data/spec/models/active_record/localizer_test_model.rb +34 -0
- data/spec/models/active_record/no_direct_assignment.rb +21 -0
- data/spec/models/active_record/no_scope.rb +21 -0
- data/spec/models/active_record/persisted_state.rb +12 -0
- data/spec/models/active_record/provided_and_persisted_state.rb +24 -0
- data/spec/models/active_record/reader.rb +7 -0
- data/spec/models/active_record/readme_job.rb +21 -0
- data/spec/models/active_record/simple_new_dsl.rb +17 -0
- data/spec/models/active_record/thief.rb +29 -0
- data/spec/models/active_record/transient.rb +6 -0
- data/spec/models/active_record/with_enum.rb +39 -0
- data/spec/models/active_record/with_false_enum.rb +31 -0
- data/spec/models/active_record/with_true_enum.rb +39 -0
- data/spec/models/active_record/writer.rb +6 -0
- data/spec/models/basic_two_state_machines_example.rb +25 -0
- data/spec/models/callbacks/basic.rb +3 -0
- data/spec/models/callbacks/basic_multiple.rb +75 -0
- data/spec/models/callbacks/guard_within_block_multiple.rb +66 -0
- data/spec/models/callbacks/multiple_transitions_transition_guard_multiple.rb +65 -0
- data/spec/models/callbacks/private_method_multiple.rb +44 -0
- data/spec/models/callbacks/with_args.rb +9 -9
- data/spec/models/callbacks/with_args_multiple.rb +61 -0
- data/spec/models/callbacks/{with_state_args.rb → with_state_arg.rb} +1 -1
- data/spec/models/callbacks/with_state_arg_multiple.rb +26 -0
- data/spec/models/complex_example.rb +222 -0
- data/spec/models/conversation.rb +47 -1
- data/spec/models/default_state.rb +12 -0
- data/spec/models/foo.rb +57 -0
- data/spec/models/foo_callback_multiple.rb +45 -0
- data/spec/models/guardian.rb +10 -0
- data/spec/models/guardian_multiple.rb +48 -0
- data/spec/models/initial_state_proc.rb +31 -0
- data/spec/models/invalid_persistor.rb +15 -0
- data/spec/models/mongo_mapper/complex_mongo_mapper_example.rb +37 -0
- data/spec/models/mongo_mapper/no_scope_mongo_mapper.rb +21 -0
- data/spec/models/mongo_mapper/simple_mongo_mapper.rb +23 -0
- data/spec/models/mongo_mapper/simple_new_dsl_mongo_mapper.rb +25 -0
- data/spec/models/mongoid/complex_mongoid_example.rb +37 -0
- data/spec/models/mongoid/no_scope_mongoid.rb +11 -0
- data/spec/models/mongoid/simple_mongoid.rb +12 -0
- data/spec/models/mongoid/simple_new_dsl_mongoid.rb +14 -1
- data/spec/models/no_initial_state.rb +25 -0
- data/spec/models/parametrised_event.rb +1 -1
- data/spec/models/parametrised_event_multiple.rb +29 -0
- data/spec/models/provided_state.rb +24 -0
- data/spec/models/sequel/complex_sequel_example.rb +45 -0
- data/spec/models/sequel/sequel_multiple.rb +25 -0
- data/spec/models/sequel/sequel_simple.rb +25 -0
- data/spec/models/silencer.rb +5 -0
- data/spec/models/simple_example.rb +15 -0
- data/spec/models/simple_multiple_example.rb +30 -0
- data/spec/models/state_machine_with_failed_event.rb +12 -0
- data/spec/models/sub_class.rb +7 -0
- data/spec/models/sub_class_with_more_states.rb +18 -0
- data/spec/models/super_class.rb +46 -0
- data/spec/models/transactor.rb +27 -0
- data/spec/models/valid_state_name.rb +23 -0
- data/spec/models/validator.rb +47 -0
- data/spec/spec_helper.rb +4 -4
- data/spec/unit/api_spec.rb +6 -1
- data/spec/unit/basic_two_state_machines_example_spec.rb +10 -0
- data/spec/unit/callback_multiple_spec.rb +295 -0
- data/spec/unit/callbacks_spec.rb +3 -2
- data/spec/unit/complex_example_spec.rb +2 -2
- data/spec/unit/complex_multiple_example_spec.rb +99 -0
- data/spec/unit/edge_cases_spec.rb +16 -0
- data/spec/unit/event_multiple_spec.rb +73 -0
- data/spec/unit/event_naming_spec.rb +2 -15
- data/spec/unit/event_spec.rb +11 -6
- data/spec/unit/guard_multiple_spec.rb +60 -0
- data/spec/unit/guard_spec.rb +12 -0
- data/spec/unit/initial_state_multiple_spec.rb +15 -0
- data/spec/unit/initial_state_spec.rb +3 -18
- data/spec/unit/inspection_multiple_spec.rb +201 -0
- data/spec/unit/inspection_spec.rb +12 -7
- data/spec/unit/localizer_spec.rb +0 -38
- data/spec/unit/persistence/active_record_persistence_multiple_spec.rb +573 -0
- data/spec/unit/persistence/active_record_persistence_spec.rb +70 -13
- data/spec/unit/persistence/mongo_mapper_persistence_multiple_spec.rb +146 -0
- data/spec/unit/persistence/mongo_mapper_persistence_spec.rb +93 -0
- data/spec/unit/persistence/mongoid_persistence_multiple_spec.rb +127 -0
- data/spec/unit/persistence/mongoid_persistence_spec.rb +79 -0
- data/spec/unit/persistence/sequel_persistence_multiple_spec.rb +153 -0
- data/spec/unit/persistence/sequel_persistence_spec.rb +20 -23
- data/spec/unit/readme_spec.rb +42 -0
- data/spec/unit/reloading_spec.rb +1 -1
- data/spec/unit/rspec_matcher_spec.rb +79 -0
- data/spec/unit/simple_example_spec.rb +26 -42
- data/spec/unit/simple_multiple_example_spec.rb +63 -0
- data/spec/unit/state_spec.rb +3 -1
- data/spec/unit/subclassing_multiple_spec.rb +39 -0
- data/spec/unit/subclassing_spec.rb +10 -10
- data/spec/unit/transition_spec.rb +39 -25
- metadata +152 -23
- data/spec/models/active_record/api.rb +0 -75
- data/spec/models/argument.rb +0 -11
- data/spec/models/auth_machine.rb +0 -88
- data/spec/models/bar.rb +0 -15
- data/spec/models/father.rb +0 -21
- data/spec/models/persistence.rb +0 -164
- data/spec/models/son.rb +0 -3
- data/spec/unit/persistence/mongoid_persistance_spec.rb +0 -152
|
@@ -4,7 +4,12 @@ describe 'transitions' do
|
|
|
4
4
|
|
|
5
5
|
it 'should raise an exception when whiny' do
|
|
6
6
|
process = ProcessWithNewDsl.new
|
|
7
|
-
expect { process.stop! }.to raise_error
|
|
7
|
+
expect { process.stop! }.to raise_error do |err|
|
|
8
|
+
expect(err.class).to eql(AASM::InvalidTransition)
|
|
9
|
+
expect(err.message).to eql("Event 'stop' cannot transition from 'sleeping'")
|
|
10
|
+
expect(err.object).to eql(process)
|
|
11
|
+
expect(err.event_name).to eql(:stop)
|
|
12
|
+
end
|
|
8
13
|
expect(process).to be_sleeping
|
|
9
14
|
end
|
|
10
15
|
|
|
@@ -26,7 +31,7 @@ describe 'transitions' do
|
|
|
26
31
|
expect(silencer).to be_smiling
|
|
27
32
|
end
|
|
28
33
|
|
|
29
|
-
it 'should call the block
|
|
34
|
+
it 'should call the block on success' do
|
|
30
35
|
silencer = Silencer.new
|
|
31
36
|
success = false
|
|
32
37
|
expect {
|
|
@@ -36,7 +41,7 @@ describe 'transitions' do
|
|
|
36
41
|
}.to change { success }.to(true)
|
|
37
42
|
end
|
|
38
43
|
|
|
39
|
-
it 'should not call the block
|
|
44
|
+
it 'should not call the block on failure' do
|
|
40
45
|
silencer = Silencer.new
|
|
41
46
|
success = false
|
|
42
47
|
expect {
|
|
@@ -48,13 +53,13 @@ describe 'transitions' do
|
|
|
48
53
|
|
|
49
54
|
end
|
|
50
55
|
|
|
51
|
-
describe 'blocks' do
|
|
52
|
-
end
|
|
53
|
-
|
|
54
56
|
describe AASM::Core::Transition do
|
|
57
|
+
let(:state_machine) { AASM::StateMachine.new(:name) }
|
|
58
|
+
let(:event) { AASM::Core::Event.new(:event, state_machine) }
|
|
59
|
+
|
|
55
60
|
it 'should set from, to, and opts attr readers' do
|
|
56
61
|
opts = {:from => 'foo', :to => 'bar', :guard => 'g'}
|
|
57
|
-
st = AASM::Core::Transition.new(opts)
|
|
62
|
+
st = AASM::Core::Transition.new(event, opts)
|
|
58
63
|
|
|
59
64
|
expect(st.from).to eq(opts[:from])
|
|
60
65
|
expect(st.to).to eq(opts[:to])
|
|
@@ -66,7 +71,7 @@ describe AASM::Core::Transition do
|
|
|
66
71
|
st = AASM::Core::Transition.allocate
|
|
67
72
|
expect(st).to receive(:warn).with('[DEPRECATION] :on_transition is deprecated, use :after instead')
|
|
68
73
|
|
|
69
|
-
st.send :initialize, opts do
|
|
74
|
+
st.send :initialize, event, opts do
|
|
70
75
|
guard :gg
|
|
71
76
|
on_transition :after_callback
|
|
72
77
|
end
|
|
@@ -76,7 +81,7 @@ describe AASM::Core::Transition do
|
|
|
76
81
|
|
|
77
82
|
it 'should set after and guard from dsl' do
|
|
78
83
|
opts = {:from => 'foo', :to => 'bar', :guard => 'g'}
|
|
79
|
-
st = AASM::Core::Transition.new(opts) do
|
|
84
|
+
st = AASM::Core::Transition.new(event, opts) do
|
|
80
85
|
guard :gg
|
|
81
86
|
after :after_callback
|
|
82
87
|
end
|
|
@@ -87,7 +92,7 @@ describe AASM::Core::Transition do
|
|
|
87
92
|
|
|
88
93
|
it 'should pass equality check if from and to are the same' do
|
|
89
94
|
opts = {:from => 'foo', :to => 'bar', :guard => 'g'}
|
|
90
|
-
st = AASM::Core::Transition.new(opts)
|
|
95
|
+
st = AASM::Core::Transition.new(event, opts)
|
|
91
96
|
|
|
92
97
|
obj = double('object')
|
|
93
98
|
allow(obj).to receive(:from).and_return(opts[:from])
|
|
@@ -98,7 +103,7 @@ describe AASM::Core::Transition do
|
|
|
98
103
|
|
|
99
104
|
it 'should fail equality check if from are not the same' do
|
|
100
105
|
opts = {:from => 'foo', :to => 'bar', :guard => 'g'}
|
|
101
|
-
st = AASM::Core::Transition.new(opts)
|
|
106
|
+
st = AASM::Core::Transition.new(event, opts)
|
|
102
107
|
|
|
103
108
|
obj = double('object')
|
|
104
109
|
allow(obj).to receive(:from).and_return('blah')
|
|
@@ -109,7 +114,7 @@ describe AASM::Core::Transition do
|
|
|
109
114
|
|
|
110
115
|
it 'should fail equality check if to are not the same' do
|
|
111
116
|
opts = {:from => 'foo', :to => 'bar', :guard => 'g'}
|
|
112
|
-
st = AASM::Core::Transition.new(opts)
|
|
117
|
+
st = AASM::Core::Transition.new(event, opts)
|
|
113
118
|
|
|
114
119
|
obj = double('object')
|
|
115
120
|
allow(obj).to receive(:from).and_return(opts[:from])
|
|
@@ -120,16 +125,19 @@ describe AASM::Core::Transition do
|
|
|
120
125
|
end
|
|
121
126
|
|
|
122
127
|
describe AASM::Core::Transition, '- when performing guard checks' do
|
|
128
|
+
let(:state_machine) { AASM::StateMachine.new(:name) }
|
|
129
|
+
let(:event) { AASM::Core::Event.new(:event, state_machine) }
|
|
130
|
+
|
|
123
131
|
it 'should return true of there is no guard' do
|
|
124
132
|
opts = {:from => 'foo', :to => 'bar'}
|
|
125
|
-
st = AASM::Core::Transition.new(opts)
|
|
133
|
+
st = AASM::Core::Transition.new(event, opts)
|
|
126
134
|
|
|
127
135
|
expect(st.allowed?(nil)).to be_truthy
|
|
128
136
|
end
|
|
129
137
|
|
|
130
138
|
it 'should call the method on the object if guard is a symbol' do
|
|
131
139
|
opts = {:from => 'foo', :to => 'bar', :guard => :test}
|
|
132
|
-
st = AASM::Core::Transition.new(opts)
|
|
140
|
+
st = AASM::Core::Transition.new(event, opts)
|
|
133
141
|
|
|
134
142
|
obj = double('object')
|
|
135
143
|
expect(obj).to receive(:test)
|
|
@@ -139,7 +147,7 @@ describe AASM::Core::Transition, '- when performing guard checks' do
|
|
|
139
147
|
|
|
140
148
|
it 'should call the method on the object if unless is a symbol' do
|
|
141
149
|
opts = {:from => 'foo', :to => 'bar', :unless => :test}
|
|
142
|
-
st = AASM::Core::Transition.new(opts)
|
|
150
|
+
st = AASM::Core::Transition.new(event, opts)
|
|
143
151
|
|
|
144
152
|
obj = double('object')
|
|
145
153
|
expect(obj).to receive(:test)
|
|
@@ -149,7 +157,7 @@ describe AASM::Core::Transition, '- when performing guard checks' do
|
|
|
149
157
|
|
|
150
158
|
it 'should call the method on the object if guard is a string' do
|
|
151
159
|
opts = {:from => 'foo', :to => 'bar', :guard => 'test'}
|
|
152
|
-
st = AASM::Core::Transition.new(opts)
|
|
160
|
+
st = AASM::Core::Transition.new(event, opts)
|
|
153
161
|
|
|
154
162
|
obj = double('object')
|
|
155
163
|
expect(obj).to receive(:test)
|
|
@@ -159,7 +167,7 @@ describe AASM::Core::Transition, '- when performing guard checks' do
|
|
|
159
167
|
|
|
160
168
|
it 'should call the method on the object if unless is a string' do
|
|
161
169
|
opts = {:from => 'foo', :to => 'bar', :unless => 'test'}
|
|
162
|
-
st = AASM::Core::Transition.new(opts)
|
|
170
|
+
st = AASM::Core::Transition.new(event, opts)
|
|
163
171
|
|
|
164
172
|
obj = double('object')
|
|
165
173
|
expect(obj).to receive(:test)
|
|
@@ -169,7 +177,7 @@ describe AASM::Core::Transition, '- when performing guard checks' do
|
|
|
169
177
|
|
|
170
178
|
it 'should call the proc passing the object if the guard is a proc' do
|
|
171
179
|
opts = {:from => 'foo', :to => 'bar', :guard => Proc.new { test }}
|
|
172
|
-
st = AASM::Core::Transition.new(opts)
|
|
180
|
+
st = AASM::Core::Transition.new(event, opts)
|
|
173
181
|
|
|
174
182
|
obj = double('object')
|
|
175
183
|
expect(obj).to receive(:test)
|
|
@@ -179,9 +187,12 @@ describe AASM::Core::Transition, '- when performing guard checks' do
|
|
|
179
187
|
end
|
|
180
188
|
|
|
181
189
|
describe AASM::Core::Transition, '- when executing the transition with a Proc' do
|
|
190
|
+
let(:state_machine) { AASM::StateMachine.new(:name) }
|
|
191
|
+
let(:event) { AASM::Core::Event.new(:event, state_machine) }
|
|
192
|
+
|
|
182
193
|
it 'should call a Proc on the object with args' do
|
|
183
194
|
opts = {:from => 'foo', :to => 'bar', :after => Proc.new {|a| test(a) }}
|
|
184
|
-
st = AASM::Core::Transition.new(opts)
|
|
195
|
+
st = AASM::Core::Transition.new(event, opts)
|
|
185
196
|
args = {:arg1 => '1', :arg2 => '2'}
|
|
186
197
|
obj = double('object', :aasm => 'aasm')
|
|
187
198
|
|
|
@@ -197,7 +208,7 @@ describe AASM::Core::Transition, '- when executing the transition with a Proc' d
|
|
|
197
208
|
prc = Proc.new { prc_object = self }
|
|
198
209
|
|
|
199
210
|
opts = {:from => 'foo', :to => 'bar', :after => prc }
|
|
200
|
-
st = AASM::Core::Transition.new(opts)
|
|
211
|
+
st = AASM::Core::Transition.new(event, opts)
|
|
201
212
|
args = {:arg1 => '1', :arg2 => '2'}
|
|
202
213
|
obj = double('object', :aasm => 'aasm')
|
|
203
214
|
|
|
@@ -207,9 +218,12 @@ describe AASM::Core::Transition, '- when executing the transition with a Proc' d
|
|
|
207
218
|
end
|
|
208
219
|
|
|
209
220
|
describe AASM::Core::Transition, '- when executing the transition with an :after method call' do
|
|
221
|
+
let(:state_machine) { AASM::StateMachine.new(:name) }
|
|
222
|
+
let(:event) { AASM::Core::Event.new(:event, state_machine) }
|
|
223
|
+
|
|
210
224
|
it 'should accept a String for the method name' do
|
|
211
225
|
opts = {:from => 'foo', :to => 'bar', :after => 'test'}
|
|
212
|
-
st = AASM::Core::Transition.new(opts)
|
|
226
|
+
st = AASM::Core::Transition.new(event, opts)
|
|
213
227
|
args = {:arg1 => '1', :arg2 => '2'}
|
|
214
228
|
obj = double('object', :aasm => 'aasm')
|
|
215
229
|
|
|
@@ -220,7 +234,7 @@ describe AASM::Core::Transition, '- when executing the transition with an :after
|
|
|
220
234
|
|
|
221
235
|
it 'should accept a Symbol for the method name' do
|
|
222
236
|
opts = {:from => 'foo', :to => 'bar', :after => :test}
|
|
223
|
-
st = AASM::Core::Transition.new(opts)
|
|
237
|
+
st = AASM::Core::Transition.new(event, opts)
|
|
224
238
|
args = {:arg1 => '1', :arg2 => '2'}
|
|
225
239
|
obj = double('object', :aasm => 'aasm')
|
|
226
240
|
|
|
@@ -231,7 +245,7 @@ describe AASM::Core::Transition, '- when executing the transition with an :after
|
|
|
231
245
|
|
|
232
246
|
it 'should pass args if the target method accepts them' do
|
|
233
247
|
opts = {:from => 'foo', :to => 'bar', :after => :test}
|
|
234
|
-
st = AASM::Core::Transition.new(opts)
|
|
248
|
+
st = AASM::Core::Transition.new(event, opts)
|
|
235
249
|
args = {:arg1 => '1', :arg2 => '2'}
|
|
236
250
|
obj = double('object', :aasm => 'aasm')
|
|
237
251
|
|
|
@@ -246,7 +260,7 @@ describe AASM::Core::Transition, '- when executing the transition with an :after
|
|
|
246
260
|
|
|
247
261
|
it 'should NOT pass args if the target method does NOT accept them' do
|
|
248
262
|
opts = {:from => 'foo', :to => 'bar', :after => :test}
|
|
249
|
-
st = AASM::Core::Transition.new(opts)
|
|
263
|
+
st = AASM::Core::Transition.new(event, opts)
|
|
250
264
|
args = {:arg1 => '1', :arg2 => '2'}
|
|
251
265
|
obj = double('object', :aasm => 'aasm')
|
|
252
266
|
|
|
@@ -261,7 +275,7 @@ describe AASM::Core::Transition, '- when executing the transition with an :after
|
|
|
261
275
|
|
|
262
276
|
it 'should allow accessing the from_state and the to_state' do
|
|
263
277
|
opts = {:from => 'foo', :to => 'bar', :after => :test}
|
|
264
|
-
transition = AASM::Core::Transition.new(opts)
|
|
278
|
+
transition = AASM::Core::Transition.new(event, opts)
|
|
265
279
|
args = {:arg1 => '1', :arg2 => '2'}
|
|
266
280
|
obj = double('object', :aasm => AASM::InstanceBase.new('object'))
|
|
267
281
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: aasm
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.5.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Scott Barron
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date:
|
|
13
|
+
date: 2016-01-06 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: rake
|
|
@@ -46,14 +46,14 @@ dependencies:
|
|
|
46
46
|
requirements:
|
|
47
47
|
- - ">="
|
|
48
48
|
- !ruby/object:Gem::Version
|
|
49
|
-
version: '
|
|
49
|
+
version: '3'
|
|
50
50
|
type: :development
|
|
51
51
|
prerelease: false
|
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
|
53
53
|
requirements:
|
|
54
54
|
- - ">="
|
|
55
55
|
- !ruby/object:Gem::Version
|
|
56
|
-
version: '
|
|
56
|
+
version: '3'
|
|
57
57
|
- !ruby/object:Gem::Dependency
|
|
58
58
|
name: pry
|
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -80,6 +80,7 @@ files:
|
|
|
80
80
|
- ".travis.yml"
|
|
81
81
|
- API
|
|
82
82
|
- CHANGELOG.md
|
|
83
|
+
- CODE_OF_CONDUCT.md
|
|
83
84
|
- Gemfile
|
|
84
85
|
- HOWTO
|
|
85
86
|
- LICENSE
|
|
@@ -91,8 +92,12 @@ files:
|
|
|
91
92
|
- callbacks.txt
|
|
92
93
|
- gemfiles/rails_3.2.gemfile
|
|
93
94
|
- gemfiles/rails_4.0.gemfile
|
|
95
|
+
- gemfiles/rails_4.0_mongo_mapper.gemfile
|
|
94
96
|
- gemfiles/rails_4.1.gemfile
|
|
97
|
+
- gemfiles/rails_4.1_mongo_mapper.gemfile
|
|
95
98
|
- gemfiles/rails_4.2.gemfile
|
|
99
|
+
- gemfiles/rails_4.2_mongo_mapper.gemfile
|
|
100
|
+
- gemfiles/rails_4.2_mongoid_5.gemfile
|
|
96
101
|
- lib/aasm.rb
|
|
97
102
|
- lib/aasm/aasm.rb
|
|
98
103
|
- lib/aasm/base.rb
|
|
@@ -107,63 +112,128 @@ files:
|
|
|
107
112
|
- lib/aasm/persistence.rb
|
|
108
113
|
- lib/aasm/persistence/active_record_persistence.rb
|
|
109
114
|
- lib/aasm/persistence/base.rb
|
|
115
|
+
- lib/aasm/persistence/mongo_mapper_persistence.rb
|
|
110
116
|
- lib/aasm/persistence/mongoid_persistence.rb
|
|
111
117
|
- lib/aasm/persistence/plain_persistence.rb
|
|
112
118
|
- lib/aasm/persistence/sequel_persistence.rb
|
|
119
|
+
- lib/aasm/rspec.rb
|
|
120
|
+
- lib/aasm/rspec/allow_event.rb
|
|
121
|
+
- lib/aasm/rspec/allow_transition_to.rb
|
|
122
|
+
- lib/aasm/rspec/have_state.rb
|
|
123
|
+
- lib/aasm/rspec/transition_from.rb
|
|
113
124
|
- lib/aasm/state_machine.rb
|
|
114
125
|
- lib/aasm/version.rb
|
|
115
126
|
- spec/database.rb
|
|
116
127
|
- spec/database.yml
|
|
117
128
|
- spec/en.yml
|
|
118
129
|
- spec/en_deprecated_style.yml
|
|
119
|
-
- spec/models/active_record/
|
|
120
|
-
- spec/models/
|
|
121
|
-
- spec/models/
|
|
122
|
-
- spec/models/
|
|
130
|
+
- spec/models/active_record/basic_active_record_two_state_machines_example.rb
|
|
131
|
+
- spec/models/active_record/complex_active_record_example.rb
|
|
132
|
+
- spec/models/active_record/derivate_new_dsl.rb
|
|
133
|
+
- spec/models/active_record/false_state.rb
|
|
134
|
+
- spec/models/active_record/gate.rb
|
|
135
|
+
- spec/models/active_record/localizer_test_model.rb
|
|
136
|
+
- spec/models/active_record/no_direct_assignment.rb
|
|
137
|
+
- spec/models/active_record/no_scope.rb
|
|
138
|
+
- spec/models/active_record/persisted_state.rb
|
|
139
|
+
- spec/models/active_record/provided_and_persisted_state.rb
|
|
140
|
+
- spec/models/active_record/reader.rb
|
|
141
|
+
- spec/models/active_record/readme_job.rb
|
|
142
|
+
- spec/models/active_record/simple_new_dsl.rb
|
|
143
|
+
- spec/models/active_record/thief.rb
|
|
144
|
+
- spec/models/active_record/transient.rb
|
|
145
|
+
- spec/models/active_record/with_enum.rb
|
|
146
|
+
- spec/models/active_record/with_false_enum.rb
|
|
147
|
+
- spec/models/active_record/with_true_enum.rb
|
|
148
|
+
- spec/models/active_record/writer.rb
|
|
149
|
+
- spec/models/basic_two_state_machines_example.rb
|
|
123
150
|
- spec/models/callbacks/basic.rb
|
|
151
|
+
- spec/models/callbacks/basic_multiple.rb
|
|
124
152
|
- spec/models/callbacks/guard_within_block.rb
|
|
153
|
+
- spec/models/callbacks/guard_within_block_multiple.rb
|
|
125
154
|
- spec/models/callbacks/multiple_transitions_transition_guard.rb
|
|
155
|
+
- spec/models/callbacks/multiple_transitions_transition_guard_multiple.rb
|
|
126
156
|
- spec/models/callbacks/private_method.rb
|
|
157
|
+
- spec/models/callbacks/private_method_multiple.rb
|
|
127
158
|
- spec/models/callbacks/with_args.rb
|
|
128
|
-
- spec/models/callbacks/
|
|
159
|
+
- spec/models/callbacks/with_args_multiple.rb
|
|
160
|
+
- spec/models/callbacks/with_state_arg.rb
|
|
161
|
+
- spec/models/callbacks/with_state_arg_multiple.rb
|
|
162
|
+
- spec/models/complex_example.rb
|
|
129
163
|
- spec/models/conversation.rb
|
|
164
|
+
- spec/models/default_state.rb
|
|
130
165
|
- spec/models/double_definer.rb
|
|
131
|
-
- spec/models/father.rb
|
|
132
166
|
- spec/models/foo.rb
|
|
167
|
+
- spec/models/foo_callback_multiple.rb
|
|
133
168
|
- spec/models/guardian.rb
|
|
169
|
+
- spec/models/guardian_multiple.rb
|
|
170
|
+
- spec/models/initial_state_proc.rb
|
|
134
171
|
- spec/models/invalid_persistor.rb
|
|
172
|
+
- spec/models/mongo_mapper/complex_mongo_mapper_example.rb
|
|
173
|
+
- spec/models/mongo_mapper/no_scope_mongo_mapper.rb
|
|
174
|
+
- spec/models/mongo_mapper/simple_mongo_mapper.rb
|
|
175
|
+
- spec/models/mongo_mapper/simple_new_dsl_mongo_mapper.rb
|
|
176
|
+
- spec/models/mongoid/complex_mongoid_example.rb
|
|
135
177
|
- spec/models/mongoid/no_scope_mongoid.rb
|
|
136
178
|
- spec/models/mongoid/simple_mongoid.rb
|
|
137
179
|
- spec/models/mongoid/simple_new_dsl_mongoid.rb
|
|
180
|
+
- spec/models/no_initial_state.rb
|
|
138
181
|
- spec/models/not_auto_loaded/process.rb
|
|
139
182
|
- spec/models/parametrised_event.rb
|
|
140
|
-
- spec/models/
|
|
183
|
+
- spec/models/parametrised_event_multiple.rb
|
|
141
184
|
- spec/models/process_with_new_dsl.rb
|
|
185
|
+
- spec/models/provided_state.rb
|
|
186
|
+
- spec/models/sequel/complex_sequel_example.rb
|
|
187
|
+
- spec/models/sequel/sequel_multiple.rb
|
|
188
|
+
- spec/models/sequel/sequel_simple.rb
|
|
142
189
|
- spec/models/silencer.rb
|
|
143
|
-
- spec/models/
|
|
190
|
+
- spec/models/simple_example.rb
|
|
191
|
+
- spec/models/simple_multiple_example.rb
|
|
192
|
+
- spec/models/state_machine_with_failed_event.rb
|
|
193
|
+
- spec/models/sub_class.rb
|
|
194
|
+
- spec/models/sub_class_with_more_states.rb
|
|
144
195
|
- spec/models/sub_classing.rb
|
|
196
|
+
- spec/models/super_class.rb
|
|
145
197
|
- spec/models/this_name_better_not_be_in_use.rb
|
|
146
198
|
- spec/models/transactor.rb
|
|
199
|
+
- spec/models/valid_state_name.rb
|
|
147
200
|
- spec/models/validator.rb
|
|
148
201
|
- spec/models/worker.rb
|
|
149
202
|
- spec/spec_helper.rb
|
|
150
203
|
- spec/unit/api_spec.rb
|
|
204
|
+
- spec/unit/basic_two_state_machines_example_spec.rb
|
|
205
|
+
- spec/unit/callback_multiple_spec.rb
|
|
151
206
|
- spec/unit/callbacks_spec.rb
|
|
152
207
|
- spec/unit/complex_example_spec.rb
|
|
208
|
+
- spec/unit/complex_multiple_example_spec.rb
|
|
209
|
+
- spec/unit/edge_cases_spec.rb
|
|
210
|
+
- spec/unit/event_multiple_spec.rb
|
|
153
211
|
- spec/unit/event_naming_spec.rb
|
|
154
212
|
- spec/unit/event_spec.rb
|
|
213
|
+
- spec/unit/guard_multiple_spec.rb
|
|
155
214
|
- spec/unit/guard_spec.rb
|
|
215
|
+
- spec/unit/initial_state_multiple_spec.rb
|
|
156
216
|
- spec/unit/initial_state_spec.rb
|
|
217
|
+
- spec/unit/inspection_multiple_spec.rb
|
|
157
218
|
- spec/unit/inspection_spec.rb
|
|
158
219
|
- spec/unit/localizer_spec.rb
|
|
159
220
|
- spec/unit/memory_leak_spec.rb
|
|
160
221
|
- spec/unit/new_dsl_spec.rb
|
|
222
|
+
- spec/unit/persistence/active_record_persistence_multiple_spec.rb
|
|
161
223
|
- spec/unit/persistence/active_record_persistence_spec.rb
|
|
162
|
-
- spec/unit/persistence/
|
|
224
|
+
- spec/unit/persistence/mongo_mapper_persistence_multiple_spec.rb
|
|
225
|
+
- spec/unit/persistence/mongo_mapper_persistence_spec.rb
|
|
226
|
+
- spec/unit/persistence/mongoid_persistence_multiple_spec.rb
|
|
227
|
+
- spec/unit/persistence/mongoid_persistence_spec.rb
|
|
228
|
+
- spec/unit/persistence/sequel_persistence_multiple_spec.rb
|
|
163
229
|
- spec/unit/persistence/sequel_persistence_spec.rb
|
|
230
|
+
- spec/unit/readme_spec.rb
|
|
164
231
|
- spec/unit/reloading_spec.rb
|
|
232
|
+
- spec/unit/rspec_matcher_spec.rb
|
|
165
233
|
- spec/unit/simple_example_spec.rb
|
|
234
|
+
- spec/unit/simple_multiple_example_spec.rb
|
|
166
235
|
- spec/unit/state_spec.rb
|
|
236
|
+
- spec/unit/subclassing_multiple_spec.rb
|
|
167
237
|
- spec/unit/subclassing_spec.rb
|
|
168
238
|
- spec/unit/transition_spec.rb
|
|
169
239
|
homepage: https://github.com/aasm/aasm
|
|
@@ -186,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
186
256
|
version: '0'
|
|
187
257
|
requirements: []
|
|
188
258
|
rubyforge_project:
|
|
189
|
-
rubygems_version: 2.
|
|
259
|
+
rubygems_version: 2.4.5
|
|
190
260
|
signing_key:
|
|
191
261
|
specification_version: 4
|
|
192
262
|
summary: State machine mixin for Ruby objects
|
|
@@ -195,53 +265,112 @@ test_files:
|
|
|
195
265
|
- spec/database.yml
|
|
196
266
|
- spec/en.yml
|
|
197
267
|
- spec/en_deprecated_style.yml
|
|
198
|
-
- spec/models/active_record/
|
|
199
|
-
- spec/models/
|
|
200
|
-
- spec/models/
|
|
201
|
-
- spec/models/
|
|
268
|
+
- spec/models/active_record/basic_active_record_two_state_machines_example.rb
|
|
269
|
+
- spec/models/active_record/complex_active_record_example.rb
|
|
270
|
+
- spec/models/active_record/derivate_new_dsl.rb
|
|
271
|
+
- spec/models/active_record/false_state.rb
|
|
272
|
+
- spec/models/active_record/gate.rb
|
|
273
|
+
- spec/models/active_record/localizer_test_model.rb
|
|
274
|
+
- spec/models/active_record/no_direct_assignment.rb
|
|
275
|
+
- spec/models/active_record/no_scope.rb
|
|
276
|
+
- spec/models/active_record/persisted_state.rb
|
|
277
|
+
- spec/models/active_record/provided_and_persisted_state.rb
|
|
278
|
+
- spec/models/active_record/reader.rb
|
|
279
|
+
- spec/models/active_record/readme_job.rb
|
|
280
|
+
- spec/models/active_record/simple_new_dsl.rb
|
|
281
|
+
- spec/models/active_record/thief.rb
|
|
282
|
+
- spec/models/active_record/transient.rb
|
|
283
|
+
- spec/models/active_record/with_enum.rb
|
|
284
|
+
- spec/models/active_record/with_false_enum.rb
|
|
285
|
+
- spec/models/active_record/with_true_enum.rb
|
|
286
|
+
- spec/models/active_record/writer.rb
|
|
287
|
+
- spec/models/basic_two_state_machines_example.rb
|
|
202
288
|
- spec/models/callbacks/basic.rb
|
|
289
|
+
- spec/models/callbacks/basic_multiple.rb
|
|
203
290
|
- spec/models/callbacks/guard_within_block.rb
|
|
291
|
+
- spec/models/callbacks/guard_within_block_multiple.rb
|
|
204
292
|
- spec/models/callbacks/multiple_transitions_transition_guard.rb
|
|
293
|
+
- spec/models/callbacks/multiple_transitions_transition_guard_multiple.rb
|
|
205
294
|
- spec/models/callbacks/private_method.rb
|
|
295
|
+
- spec/models/callbacks/private_method_multiple.rb
|
|
206
296
|
- spec/models/callbacks/with_args.rb
|
|
207
|
-
- spec/models/callbacks/
|
|
297
|
+
- spec/models/callbacks/with_args_multiple.rb
|
|
298
|
+
- spec/models/callbacks/with_state_arg.rb
|
|
299
|
+
- spec/models/callbacks/with_state_arg_multiple.rb
|
|
300
|
+
- spec/models/complex_example.rb
|
|
208
301
|
- spec/models/conversation.rb
|
|
302
|
+
- spec/models/default_state.rb
|
|
209
303
|
- spec/models/double_definer.rb
|
|
210
|
-
- spec/models/father.rb
|
|
211
304
|
- spec/models/foo.rb
|
|
305
|
+
- spec/models/foo_callback_multiple.rb
|
|
212
306
|
- spec/models/guardian.rb
|
|
307
|
+
- spec/models/guardian_multiple.rb
|
|
308
|
+
- spec/models/initial_state_proc.rb
|
|
213
309
|
- spec/models/invalid_persistor.rb
|
|
310
|
+
- spec/models/mongo_mapper/complex_mongo_mapper_example.rb
|
|
311
|
+
- spec/models/mongo_mapper/no_scope_mongo_mapper.rb
|
|
312
|
+
- spec/models/mongo_mapper/simple_mongo_mapper.rb
|
|
313
|
+
- spec/models/mongo_mapper/simple_new_dsl_mongo_mapper.rb
|
|
314
|
+
- spec/models/mongoid/complex_mongoid_example.rb
|
|
214
315
|
- spec/models/mongoid/no_scope_mongoid.rb
|
|
215
316
|
- spec/models/mongoid/simple_mongoid.rb
|
|
216
317
|
- spec/models/mongoid/simple_new_dsl_mongoid.rb
|
|
318
|
+
- spec/models/no_initial_state.rb
|
|
217
319
|
- spec/models/not_auto_loaded/process.rb
|
|
218
320
|
- spec/models/parametrised_event.rb
|
|
219
|
-
- spec/models/
|
|
321
|
+
- spec/models/parametrised_event_multiple.rb
|
|
220
322
|
- spec/models/process_with_new_dsl.rb
|
|
323
|
+
- spec/models/provided_state.rb
|
|
324
|
+
- spec/models/sequel/complex_sequel_example.rb
|
|
325
|
+
- spec/models/sequel/sequel_multiple.rb
|
|
326
|
+
- spec/models/sequel/sequel_simple.rb
|
|
221
327
|
- spec/models/silencer.rb
|
|
222
|
-
- spec/models/
|
|
328
|
+
- spec/models/simple_example.rb
|
|
329
|
+
- spec/models/simple_multiple_example.rb
|
|
330
|
+
- spec/models/state_machine_with_failed_event.rb
|
|
331
|
+
- spec/models/sub_class.rb
|
|
332
|
+
- spec/models/sub_class_with_more_states.rb
|
|
223
333
|
- spec/models/sub_classing.rb
|
|
334
|
+
- spec/models/super_class.rb
|
|
224
335
|
- spec/models/this_name_better_not_be_in_use.rb
|
|
225
336
|
- spec/models/transactor.rb
|
|
337
|
+
- spec/models/valid_state_name.rb
|
|
226
338
|
- spec/models/validator.rb
|
|
227
339
|
- spec/models/worker.rb
|
|
228
340
|
- spec/spec_helper.rb
|
|
229
341
|
- spec/unit/api_spec.rb
|
|
342
|
+
- spec/unit/basic_two_state_machines_example_spec.rb
|
|
343
|
+
- spec/unit/callback_multiple_spec.rb
|
|
230
344
|
- spec/unit/callbacks_spec.rb
|
|
231
345
|
- spec/unit/complex_example_spec.rb
|
|
346
|
+
- spec/unit/complex_multiple_example_spec.rb
|
|
347
|
+
- spec/unit/edge_cases_spec.rb
|
|
348
|
+
- spec/unit/event_multiple_spec.rb
|
|
232
349
|
- spec/unit/event_naming_spec.rb
|
|
233
350
|
- spec/unit/event_spec.rb
|
|
351
|
+
- spec/unit/guard_multiple_spec.rb
|
|
234
352
|
- spec/unit/guard_spec.rb
|
|
353
|
+
- spec/unit/initial_state_multiple_spec.rb
|
|
235
354
|
- spec/unit/initial_state_spec.rb
|
|
355
|
+
- spec/unit/inspection_multiple_spec.rb
|
|
236
356
|
- spec/unit/inspection_spec.rb
|
|
237
357
|
- spec/unit/localizer_spec.rb
|
|
238
358
|
- spec/unit/memory_leak_spec.rb
|
|
239
359
|
- spec/unit/new_dsl_spec.rb
|
|
360
|
+
- spec/unit/persistence/active_record_persistence_multiple_spec.rb
|
|
240
361
|
- spec/unit/persistence/active_record_persistence_spec.rb
|
|
241
|
-
- spec/unit/persistence/
|
|
362
|
+
- spec/unit/persistence/mongo_mapper_persistence_multiple_spec.rb
|
|
363
|
+
- spec/unit/persistence/mongo_mapper_persistence_spec.rb
|
|
364
|
+
- spec/unit/persistence/mongoid_persistence_multiple_spec.rb
|
|
365
|
+
- spec/unit/persistence/mongoid_persistence_spec.rb
|
|
366
|
+
- spec/unit/persistence/sequel_persistence_multiple_spec.rb
|
|
242
367
|
- spec/unit/persistence/sequel_persistence_spec.rb
|
|
368
|
+
- spec/unit/readme_spec.rb
|
|
243
369
|
- spec/unit/reloading_spec.rb
|
|
370
|
+
- spec/unit/rspec_matcher_spec.rb
|
|
244
371
|
- spec/unit/simple_example_spec.rb
|
|
372
|
+
- spec/unit/simple_multiple_example_spec.rb
|
|
245
373
|
- spec/unit/state_spec.rb
|
|
374
|
+
- spec/unit/subclassing_multiple_spec.rb
|
|
246
375
|
- spec/unit/subclassing_spec.rb
|
|
247
376
|
- spec/unit/transition_spec.rb
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
class DefaultState
|
|
2
|
-
attr_accessor :transient_store, :persisted_store
|
|
3
|
-
include AASM
|
|
4
|
-
aasm do
|
|
5
|
-
state :alpha, :initial => true
|
|
6
|
-
state :beta
|
|
7
|
-
state :gamma
|
|
8
|
-
event :release do
|
|
9
|
-
transitions :from => [:alpha, :beta, :gamma], :to => :beta
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
class ProvidedState
|
|
15
|
-
attr_accessor :transient_store, :persisted_store
|
|
16
|
-
include AASM
|
|
17
|
-
aasm do
|
|
18
|
-
state :alpha, :initial => true
|
|
19
|
-
state :beta
|
|
20
|
-
state :gamma
|
|
21
|
-
event :release do
|
|
22
|
-
transitions :from => [:alpha, :beta, :gamma], :to => :beta
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def aasm_read_state
|
|
27
|
-
:beta
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def aasm_write_state(new_state)
|
|
31
|
-
@persisted_store = new_state
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def aasm_write_state_without_persistence(new_state)
|
|
35
|
-
@transient_store = new_state
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
class PersistedState < ActiveRecord::Base
|
|
40
|
-
attr_accessor :transient_store, :persisted_store
|
|
41
|
-
include AASM
|
|
42
|
-
aasm do
|
|
43
|
-
state :alpha, :initial => true
|
|
44
|
-
state :beta
|
|
45
|
-
state :gamma
|
|
46
|
-
event :release do
|
|
47
|
-
transitions :from => [:alpha, :beta, :gamma], :to => :beta
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
class ProvidedAndPersistedState < ActiveRecord::Base
|
|
53
|
-
attr_accessor :transient_store, :persisted_store
|
|
54
|
-
include AASM
|
|
55
|
-
aasm do
|
|
56
|
-
state :alpha, :initial => true
|
|
57
|
-
state :beta
|
|
58
|
-
state :gamma
|
|
59
|
-
event :release do
|
|
60
|
-
transitions :from => [:alpha, :beta, :gamma], :to => :beta
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def aasm_read_state
|
|
65
|
-
:gamma
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def aasm_write_state(new_state)
|
|
69
|
-
@persisted_store = new_state
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def aasm_write_state_without_persistence(new_state)
|
|
73
|
-
@transient_store = new_state
|
|
74
|
-
end
|
|
75
|
-
end
|