aasm 4.1.1 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -1
  3. data/CODE_OF_CONDUCT.md +13 -0
  4. data/Gemfile +1 -1
  5. data/LICENSE +1 -1
  6. data/README.md +9 -0
  7. data/aasm.gemspec +1 -1
  8. data/lib/aasm/base.rb +12 -4
  9. data/lib/aasm/persistence/active_record_persistence.rb +1 -1
  10. data/lib/aasm/version.rb +1 -1
  11. data/spec/models/active_record/derivate_new_dsl.rb +3 -0
  12. data/spec/models/active_record/false_state.rb +17 -0
  13. data/spec/models/active_record/gate.rb +19 -0
  14. data/spec/models/active_record/localizer_test_model.rb +34 -0
  15. data/spec/models/active_record/no_direct_assignment.rb +10 -0
  16. data/spec/models/active_record/no_scope.rb +10 -0
  17. data/spec/models/active_record/persisted_state.rb +12 -0
  18. data/spec/models/active_record/provided_and_persisted_state.rb +24 -0
  19. data/spec/models/active_record/reader.rb +7 -0
  20. data/spec/models/active_record/simple_new_dsl.rb +8 -0
  21. data/spec/models/active_record/thief.rb +14 -0
  22. data/spec/models/active_record/transient.rb +6 -0
  23. data/spec/models/active_record/with_enum.rb +19 -0
  24. data/spec/models/active_record/with_false_enum.rb +15 -0
  25. data/spec/models/active_record/with_true_enum.rb +19 -0
  26. data/spec/models/active_record/writer.rb +6 -0
  27. data/spec/models/{auth_machine.rb → complex_example.rb} +1 -1
  28. data/spec/models/default_state.rb +12 -0
  29. data/spec/models/initial_state_proc.rb +15 -0
  30. data/spec/models/{bar.rb → no_initial_state.rb} +1 -4
  31. data/spec/models/provided_state.rb +24 -0
  32. data/spec/models/simple_example.rb +15 -0
  33. data/spec/models/state_machine_with_failed_event.rb +12 -0
  34. data/spec/models/sub_class.rb +3 -0
  35. data/spec/models/sub_class_with_more_states.rb +7 -0
  36. data/spec/models/super_class.rb +18 -0
  37. data/spec/models/{argument.rb → valid_state_name.rb} +1 -1
  38. data/spec/models/validator.rb +4 -4
  39. data/spec/spec_helper.rb +1 -1
  40. data/spec/unit/api_spec.rb +6 -1
  41. data/spec/unit/complex_example_spec.rb +2 -2
  42. data/spec/unit/event_naming_spec.rb +2 -15
  43. data/spec/unit/initial_state_spec.rb +3 -18
  44. data/spec/unit/inspection_spec.rb +7 -7
  45. data/spec/unit/localizer_spec.rb +0 -38
  46. data/spec/unit/persistence/active_record_persistence_spec.rb +21 -3
  47. data/spec/unit/simple_example_spec.rb +26 -42
  48. data/spec/unit/subclassing_spec.rb +10 -10
  49. metadata +60 -19
  50. data/spec/models/active_record/api.rb +0 -75
  51. data/spec/models/father.rb +0 -21
  52. data/spec/models/persistence.rb +0 -164
  53. data/spec/models/son.rb +0 -3
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.1.1
4
+ version: 4.2.0
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: 2015-05-13 00:00:00.000000000 Z
13
+ date: 2015-06-23 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: '0'
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: '0'
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
@@ -120,21 +121,35 @@ files:
120
121
  - spec/database.yml
121
122
  - spec/en.yml
122
123
  - spec/en_deprecated_style.yml
123
- - spec/models/active_record/api.rb
124
- - spec/models/argument.rb
125
- - spec/models/auth_machine.rb
126
- - spec/models/bar.rb
124
+ - spec/models/active_record/derivate_new_dsl.rb
125
+ - spec/models/active_record/false_state.rb
126
+ - spec/models/active_record/gate.rb
127
+ - spec/models/active_record/localizer_test_model.rb
128
+ - spec/models/active_record/no_direct_assignment.rb
129
+ - spec/models/active_record/no_scope.rb
130
+ - spec/models/active_record/persisted_state.rb
131
+ - spec/models/active_record/provided_and_persisted_state.rb
132
+ - spec/models/active_record/reader.rb
133
+ - spec/models/active_record/simple_new_dsl.rb
134
+ - spec/models/active_record/thief.rb
135
+ - spec/models/active_record/transient.rb
136
+ - spec/models/active_record/with_enum.rb
137
+ - spec/models/active_record/with_false_enum.rb
138
+ - spec/models/active_record/with_true_enum.rb
139
+ - spec/models/active_record/writer.rb
127
140
  - spec/models/callbacks/basic.rb
128
141
  - spec/models/callbacks/guard_within_block.rb
129
142
  - spec/models/callbacks/multiple_transitions_transition_guard.rb
130
143
  - spec/models/callbacks/private_method.rb
131
144
  - spec/models/callbacks/with_args.rb
132
145
  - spec/models/callbacks/with_state_args.rb
146
+ - spec/models/complex_example.rb
133
147
  - spec/models/conversation.rb
148
+ - spec/models/default_state.rb
134
149
  - spec/models/double_definer.rb
135
- - spec/models/father.rb
136
150
  - spec/models/foo.rb
137
151
  - spec/models/guardian.rb
152
+ - spec/models/initial_state_proc.rb
138
153
  - spec/models/invalid_persistor.rb
139
154
  - spec/models/mongo_mapper/no_scope_mongo_mapper.rb
140
155
  - spec/models/mongo_mapper/simple_mongo_mapper.rb
@@ -142,15 +157,21 @@ files:
142
157
  - spec/models/mongoid/no_scope_mongoid.rb
143
158
  - spec/models/mongoid/simple_mongoid.rb
144
159
  - spec/models/mongoid/simple_new_dsl_mongoid.rb
160
+ - spec/models/no_initial_state.rb
145
161
  - spec/models/not_auto_loaded/process.rb
146
162
  - spec/models/parametrised_event.rb
147
- - spec/models/persistence.rb
148
163
  - spec/models/process_with_new_dsl.rb
164
+ - spec/models/provided_state.rb
149
165
  - spec/models/silencer.rb
150
- - spec/models/son.rb
166
+ - spec/models/simple_example.rb
167
+ - spec/models/state_machine_with_failed_event.rb
168
+ - spec/models/sub_class.rb
169
+ - spec/models/sub_class_with_more_states.rb
151
170
  - spec/models/sub_classing.rb
171
+ - spec/models/super_class.rb
152
172
  - spec/models/this_name_better_not_be_in_use.rb
153
173
  - spec/models/transactor.rb
174
+ - spec/models/valid_state_name.rb
154
175
  - spec/models/validator.rb
155
176
  - spec/models/worker.rb
156
177
  - spec/spec_helper.rb
@@ -194,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
215
  version: '0'
195
216
  requirements: []
196
217
  rubyforge_project:
197
- rubygems_version: 2.2.2
218
+ rubygems_version: 2.4.5
198
219
  signing_key:
199
220
  specification_version: 4
200
221
  summary: State machine mixin for Ruby objects
@@ -203,21 +224,35 @@ test_files:
203
224
  - spec/database.yml
204
225
  - spec/en.yml
205
226
  - spec/en_deprecated_style.yml
206
- - spec/models/active_record/api.rb
207
- - spec/models/argument.rb
208
- - spec/models/auth_machine.rb
209
- - spec/models/bar.rb
227
+ - spec/models/active_record/derivate_new_dsl.rb
228
+ - spec/models/active_record/false_state.rb
229
+ - spec/models/active_record/gate.rb
230
+ - spec/models/active_record/localizer_test_model.rb
231
+ - spec/models/active_record/no_direct_assignment.rb
232
+ - spec/models/active_record/no_scope.rb
233
+ - spec/models/active_record/persisted_state.rb
234
+ - spec/models/active_record/provided_and_persisted_state.rb
235
+ - spec/models/active_record/reader.rb
236
+ - spec/models/active_record/simple_new_dsl.rb
237
+ - spec/models/active_record/thief.rb
238
+ - spec/models/active_record/transient.rb
239
+ - spec/models/active_record/with_enum.rb
240
+ - spec/models/active_record/with_false_enum.rb
241
+ - spec/models/active_record/with_true_enum.rb
242
+ - spec/models/active_record/writer.rb
210
243
  - spec/models/callbacks/basic.rb
211
244
  - spec/models/callbacks/guard_within_block.rb
212
245
  - spec/models/callbacks/multiple_transitions_transition_guard.rb
213
246
  - spec/models/callbacks/private_method.rb
214
247
  - spec/models/callbacks/with_args.rb
215
248
  - spec/models/callbacks/with_state_args.rb
249
+ - spec/models/complex_example.rb
216
250
  - spec/models/conversation.rb
251
+ - spec/models/default_state.rb
217
252
  - spec/models/double_definer.rb
218
- - spec/models/father.rb
219
253
  - spec/models/foo.rb
220
254
  - spec/models/guardian.rb
255
+ - spec/models/initial_state_proc.rb
221
256
  - spec/models/invalid_persistor.rb
222
257
  - spec/models/mongo_mapper/no_scope_mongo_mapper.rb
223
258
  - spec/models/mongo_mapper/simple_mongo_mapper.rb
@@ -225,15 +260,21 @@ test_files:
225
260
  - spec/models/mongoid/no_scope_mongoid.rb
226
261
  - spec/models/mongoid/simple_mongoid.rb
227
262
  - spec/models/mongoid/simple_new_dsl_mongoid.rb
263
+ - spec/models/no_initial_state.rb
228
264
  - spec/models/not_auto_loaded/process.rb
229
265
  - spec/models/parametrised_event.rb
230
- - spec/models/persistence.rb
231
266
  - spec/models/process_with_new_dsl.rb
267
+ - spec/models/provided_state.rb
232
268
  - spec/models/silencer.rb
233
- - spec/models/son.rb
269
+ - spec/models/simple_example.rb
270
+ - spec/models/state_machine_with_failed_event.rb
271
+ - spec/models/sub_class.rb
272
+ - spec/models/sub_class_with_more_states.rb
234
273
  - spec/models/sub_classing.rb
274
+ - spec/models/super_class.rb
235
275
  - spec/models/this_name_better_not_be_in_use.rb
236
276
  - spec/models/transactor.rb
277
+ - spec/models/valid_state_name.rb
237
278
  - spec/models/validator.rb
238
279
  - spec/models/worker.rb
239
280
  - spec/spec_helper.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
@@ -1,21 +0,0 @@
1
- require 'active_record'
2
-
3
- class Father < ActiveRecord::Base
4
- include AASM
5
-
6
- aasm do
7
- state :missing_details, :initial => true
8
- state :pending_details_confirmation
9
-
10
- event :add_details do
11
- transitions :from => :missing_details, :to => :pending_details_confirmation
12
- end
13
- end
14
-
15
- def update_state
16
- if may_add_details?
17
- add_details!
18
- end
19
- end
20
-
21
- end
@@ -1,164 +0,0 @@
1
- class Gate < ActiveRecord::Base
2
- include AASM
3
-
4
- # Fake this column for testing purposes
5
- # attr_accessor :aasm_state
6
-
7
- def value
8
- 'value'
9
- end
10
-
11
- aasm do
12
- state :opened
13
- state :closed
14
-
15
- event :view do
16
- transitions :to => :read, :from => [:needs_attention]
17
- end
18
- end
19
- end
20
-
21
- class FalseState < ActiveRecord::Base
22
- include AASM
23
-
24
- def initialize(*args)
25
- super
26
- self.aasm_state = false
27
- end
28
-
29
- aasm do
30
- state :opened
31
- state :closed
32
-
33
- event :view do
34
- transitions :to => :read, :from => [:needs_attention]
35
- end
36
- end
37
- end
38
-
39
- class WithEnum < ActiveRecord::Base
40
- include AASM
41
-
42
- # Fake this column for testing purposes
43
- attr_accessor :aasm_state
44
-
45
- def self.test
46
- {}
47
- end
48
-
49
- aasm :enum => :test do
50
- state :opened
51
- state :closed
52
-
53
- event :view do
54
- transitions :to => :read, :from => [:needs_attention]
55
- end
56
- end
57
- end
58
-
59
- class WithTrueEnum < ActiveRecord::Base
60
- include AASM
61
-
62
- # Fake this column for testing purposes
63
- attr_accessor :aasm_state
64
-
65
- def value
66
- 'value'
67
- end
68
-
69
- aasm :enum => true do
70
- state :opened
71
- state :closed
72
-
73
- event :view do
74
- transitions :to => :read, :from => [:needs_attention]
75
- end
76
- end
77
- end
78
-
79
- class WithFalseEnum < ActiveRecord::Base
80
- include AASM
81
-
82
- # Fake this column for testing purposes
83
- attr_accessor :aasm_state
84
-
85
- aasm :enum => false do
86
- state :opened
87
- state :closed
88
-
89
- event :view do
90
- transitions :to => :read, :from => [:needs_attention]
91
- end
92
- end
93
- end
94
-
95
- class Reader < ActiveRecord::Base
96
- include AASM
97
-
98
- def aasm_read_state
99
- "fi"
100
- end
101
- end
102
-
103
- class Writer < ActiveRecord::Base
104
- def aasm_write_state(state)
105
- "fo"
106
- end
107
- include AASM
108
- end
109
-
110
- class Transient < ActiveRecord::Base
111
- def aasm_write_state_without_persistence(state)
112
- "fum"
113
- end
114
- include AASM
115
- end
116
-
117
- class SimpleNewDsl < ActiveRecord::Base
118
- include AASM
119
- aasm :column => :status
120
- aasm do
121
- state :unknown_scope
122
- state :new
123
- end
124
- end
125
-
126
- class NoScope < ActiveRecord::Base
127
- include AASM
128
- aasm :create_scopes => false do
129
- state :pending, :initial => true
130
- state :running
131
- event :run do
132
- transitions :from => :pending, :to => :running
133
- end
134
- end
135
- end
136
-
137
- class NoDirectAssignment < ActiveRecord::Base
138
- include AASM
139
- aasm :no_direct_assignment => true do
140
- state :pending, :initial => true
141
- state :running
142
- event :run do
143
- transitions :from => :pending, :to => :running
144
- end
145
- end
146
- end
147
-
148
- class DerivateNewDsl < SimpleNewDsl
149
- end
150
-
151
- class Thief < ActiveRecord::Base
152
- if ActiveRecord::VERSION::MAJOR >= 3
153
- self.table_name = 'thieves'
154
- else
155
- set_table_name "thieves"
156
- end
157
- include AASM
158
- aasm do
159
- state :rich
160
- state :jailed
161
- initial_state Proc.new {|thief| thief.skilled ? :rich : :jailed }
162
- end
163
- attr_accessor :skilled, :aasm_state
164
- end
@@ -1,3 +0,0 @@
1
- class Son < Father
2
- include AASM
3
- end