statesman 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/CHANGELOG.md +4 -0
- data/README.md +5 -6
- data/lib/statesman/adapters/active_record.rb +2 -5
- data/lib/statesman/exceptions.rb +29 -2
- data/lib/statesman/version.rb +1 -1
- data/spec/spec_helper.rb +7 -1
- data/spec/support/generators_shared_examples.rb +1 -0
- data/statesman.gemspec +2 -1
- metadata +50 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8247dd4b145c4c16a848f6cba121782199a05f43
|
4
|
+
data.tar.gz: 2f4b476e0b585f432f06985d759357d84f1ac1d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52b5b0d12f0b0741874afa857633c91e0eeba7c79678cb8f4da9d474b2227f7ca870cfa5ead883ad780a503a77028de7fa830e890e7d5611683245da0f00500d
|
7
|
+
data.tar.gz: df47a34f64bcea46519b56c450ceb0cec66233316fb03ff515578074babb6ecdcb98136ff357e8c7fb7fbf12359187c320f1101abd7aab97e1dab936ebfab2d3
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## v1.2.4 16 June 2015
|
2
|
+
|
3
|
+
- Clarify error messages when misusing `Statesman::Adapters::ActiveRecordTransition` (patch by [@isaacseymour](https://github.com/isaacseymour))
|
4
|
+
|
1
5
|
## v1.2.3 14 April 2015
|
2
6
|
|
3
7
|
- Fix use of most_recent column in MySQL (partial indexes aren't supported) (patch by [@greysteil](https://github.com/greysteil))
|
data/README.md
CHANGED
@@ -200,7 +200,7 @@ an array of states (`.transition(from: :some_state, to: [:another_state, :some_o
|
|
200
200
|
|
201
201
|
#### `Machine.guard_transition`
|
202
202
|
```ruby
|
203
|
-
Machine.guard_transition(from: :some_state, to: another_state) do |object|
|
203
|
+
Machine.guard_transition(from: :some_state, to: :another_state) do |object|
|
204
204
|
object.some_boolean?
|
205
205
|
end
|
206
206
|
```
|
@@ -210,7 +210,7 @@ be idempotent as it could be called many times.
|
|
210
210
|
|
211
211
|
#### `Machine.before_transition`
|
212
212
|
```ruby
|
213
|
-
Machine.before_transition(from: :some_state, to: another_state) do |object|
|
213
|
+
Machine.before_transition(from: :some_state, to: :another_state) do |object|
|
214
214
|
object.side_effect
|
215
215
|
end
|
216
216
|
```
|
@@ -220,7 +220,7 @@ have side-effects as it will only be run once immediately before the transition.
|
|
220
220
|
|
221
221
|
#### `Machine.after_transition`
|
222
222
|
```ruby
|
223
|
-
Machine.after_transition(from: :some_state, to: another_state) do |object, transition|
|
223
|
+
Machine.after_transition(from: :some_state, to: :another_state) do |object, transition|
|
224
224
|
object.side_effect
|
225
225
|
end
|
226
226
|
```
|
@@ -394,9 +394,8 @@ Callbacks are tested by asserting that the action they perform occurs:
|
|
394
394
|
describe "some callback" do
|
395
395
|
it "adds one to the count property on the model" do
|
396
396
|
expect { some_model.transition_to!(:some_state) }.
|
397
|
-
to change {
|
398
|
-
|
399
|
-
}.by(1)
|
397
|
+
to change { some_model.reload.count }.
|
398
|
+
by(1)
|
400
399
|
end
|
401
400
|
end
|
402
401
|
```
|
@@ -21,12 +21,9 @@ module Statesman
|
|
21
21
|
serialized = serialized?(transition_class)
|
22
22
|
column_type = transition_class.columns_hash['metadata'].sql_type
|
23
23
|
if !serialized && !JSON_COLUMN_TYPES.include?(column_type)
|
24
|
-
raise UnserializedMetadataError
|
25
|
-
"#{transition_class.name}#metadata is not serialized"
|
24
|
+
raise UnserializedMetadataError.new(transition_class.name)
|
26
25
|
elsif serialized && JSON_COLUMN_TYPES.include?(column_type)
|
27
|
-
raise IncompatibleSerializationError
|
28
|
-
"#{transition_class.name}#metadata column type cannot be json
|
29
|
-
and serialized simultaneously"
|
26
|
+
raise IncompatibleSerializationError.new(transition_class.name)
|
30
27
|
end
|
31
28
|
@transition_class = transition_class
|
32
29
|
@parent_model = parent_model
|
data/lib/statesman/exceptions.rb
CHANGED
@@ -4,7 +4,34 @@ module Statesman
|
|
4
4
|
class InvalidCallbackError < StandardError; end
|
5
5
|
class GuardFailedError < StandardError; end
|
6
6
|
class TransitionFailedError < StandardError; end
|
7
|
-
class UnserializedMetadataError < StandardError; end
|
8
|
-
class IncompatibleSerializationError < StandardError; end
|
9
7
|
class TransitionConflictError < StandardError; end
|
8
|
+
|
9
|
+
class UnserializedMetadataError < StandardError
|
10
|
+
def initialize(transition_class_name)
|
11
|
+
super(_message(transition_class_name))
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def _message(transition_class_name)
|
17
|
+
"#{transition_class_name}#metadata is not serialized. If you " \
|
18
|
+
"are using a non-json column type, you should `include " \
|
19
|
+
"Statesman::Adapters::ActiveRecordTransition`"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class IncompatibleSerializationError < StandardError
|
24
|
+
def initialize(transition_class_name)
|
25
|
+
super(_message(transition_class_name))
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def _message(transition_class_name)
|
31
|
+
"#{transition_class_name}#metadata column type cannot be json " \
|
32
|
+
"and serialized simultaneously. If you are using a json " \
|
33
|
+
"column type, it is not necessary to `include " \
|
34
|
+
"Statesman::Adapters::ActiveRecordTransition`"
|
35
|
+
end
|
36
|
+
end
|
10
37
|
end
|
data/lib/statesman/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
require "statesman"
|
2
2
|
require "sqlite3"
|
3
3
|
require "active_record"
|
4
|
+
# We have to include all of Rails to make rspec-rails work
|
5
|
+
require "rails"
|
6
|
+
require "action_view"
|
7
|
+
require "action_dispatch"
|
8
|
+
require "action_controller"
|
9
|
+
require "rspec/rails"
|
4
10
|
require "support/active_record"
|
5
11
|
require "mongoid"
|
6
|
-
require
|
12
|
+
require "rspec/its"
|
7
13
|
|
8
14
|
RSpec.configure do |config|
|
9
15
|
config.raise_errors_for_deprecations!
|
data/statesman.gemspec
CHANGED
@@ -21,13 +21,14 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
spec.add_development_dependency "rspec", "~> 3.1"
|
24
|
+
spec.add_development_dependency "rspec-rails", "~> 3.1"
|
24
25
|
spec.add_development_dependency "rspec-its", "~> 1.1"
|
25
26
|
spec.add_development_dependency "guard-rspec", "~> 4.3"
|
26
27
|
spec.add_development_dependency "rubocop", "~> 0.30.0"
|
27
28
|
spec.add_development_dependency "guard-rubocop", "~> 1.2"
|
28
29
|
spec.add_development_dependency "sqlite3", "~> 1.3"
|
29
30
|
spec.add_development_dependency "mongoid", ">= 3.1"
|
30
|
-
spec.add_development_dependency "
|
31
|
+
spec.add_development_dependency "rails", ">= 3.2"
|
31
32
|
spec.add_development_dependency "pg", "~> 0.18"
|
32
33
|
spec.add_development_dependency "mysql2", "~> 0.3"
|
33
34
|
spec.add_development_dependency "ammeter", "~> 1.1"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statesman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harry Marr
|
@@ -9,188 +9,202 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-06-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - ~>
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '1.3'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - ~>
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '1.3'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rspec
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - ~>
|
46
|
+
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '3.1'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - ~>
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '3.1'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rspec-rails
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.1'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
54
68
|
- !ruby/object:Gem::Version
|
55
69
|
version: '3.1'
|
56
70
|
- !ruby/object:Gem::Dependency
|
57
71
|
name: rspec-its
|
58
72
|
requirement: !ruby/object:Gem::Requirement
|
59
73
|
requirements:
|
60
|
-
- - ~>
|
74
|
+
- - "~>"
|
61
75
|
- !ruby/object:Gem::Version
|
62
76
|
version: '1.1'
|
63
77
|
type: :development
|
64
78
|
prerelease: false
|
65
79
|
version_requirements: !ruby/object:Gem::Requirement
|
66
80
|
requirements:
|
67
|
-
- - ~>
|
81
|
+
- - "~>"
|
68
82
|
- !ruby/object:Gem::Version
|
69
83
|
version: '1.1'
|
70
84
|
- !ruby/object:Gem::Dependency
|
71
85
|
name: guard-rspec
|
72
86
|
requirement: !ruby/object:Gem::Requirement
|
73
87
|
requirements:
|
74
|
-
- - ~>
|
88
|
+
- - "~>"
|
75
89
|
- !ruby/object:Gem::Version
|
76
90
|
version: '4.3'
|
77
91
|
type: :development
|
78
92
|
prerelease: false
|
79
93
|
version_requirements: !ruby/object:Gem::Requirement
|
80
94
|
requirements:
|
81
|
-
- - ~>
|
95
|
+
- - "~>"
|
82
96
|
- !ruby/object:Gem::Version
|
83
97
|
version: '4.3'
|
84
98
|
- !ruby/object:Gem::Dependency
|
85
99
|
name: rubocop
|
86
100
|
requirement: !ruby/object:Gem::Requirement
|
87
101
|
requirements:
|
88
|
-
- - ~>
|
102
|
+
- - "~>"
|
89
103
|
- !ruby/object:Gem::Version
|
90
104
|
version: 0.30.0
|
91
105
|
type: :development
|
92
106
|
prerelease: false
|
93
107
|
version_requirements: !ruby/object:Gem::Requirement
|
94
108
|
requirements:
|
95
|
-
- - ~>
|
109
|
+
- - "~>"
|
96
110
|
- !ruby/object:Gem::Version
|
97
111
|
version: 0.30.0
|
98
112
|
- !ruby/object:Gem::Dependency
|
99
113
|
name: guard-rubocop
|
100
114
|
requirement: !ruby/object:Gem::Requirement
|
101
115
|
requirements:
|
102
|
-
- - ~>
|
116
|
+
- - "~>"
|
103
117
|
- !ruby/object:Gem::Version
|
104
118
|
version: '1.2'
|
105
119
|
type: :development
|
106
120
|
prerelease: false
|
107
121
|
version_requirements: !ruby/object:Gem::Requirement
|
108
122
|
requirements:
|
109
|
-
- - ~>
|
123
|
+
- - "~>"
|
110
124
|
- !ruby/object:Gem::Version
|
111
125
|
version: '1.2'
|
112
126
|
- !ruby/object:Gem::Dependency
|
113
127
|
name: sqlite3
|
114
128
|
requirement: !ruby/object:Gem::Requirement
|
115
129
|
requirements:
|
116
|
-
- - ~>
|
130
|
+
- - "~>"
|
117
131
|
- !ruby/object:Gem::Version
|
118
132
|
version: '1.3'
|
119
133
|
type: :development
|
120
134
|
prerelease: false
|
121
135
|
version_requirements: !ruby/object:Gem::Requirement
|
122
136
|
requirements:
|
123
|
-
- - ~>
|
137
|
+
- - "~>"
|
124
138
|
- !ruby/object:Gem::Version
|
125
139
|
version: '1.3'
|
126
140
|
- !ruby/object:Gem::Dependency
|
127
141
|
name: mongoid
|
128
142
|
requirement: !ruby/object:Gem::Requirement
|
129
143
|
requirements:
|
130
|
-
- -
|
144
|
+
- - ">="
|
131
145
|
- !ruby/object:Gem::Version
|
132
146
|
version: '3.1'
|
133
147
|
type: :development
|
134
148
|
prerelease: false
|
135
149
|
version_requirements: !ruby/object:Gem::Requirement
|
136
150
|
requirements:
|
137
|
-
- -
|
151
|
+
- - ">="
|
138
152
|
- !ruby/object:Gem::Version
|
139
153
|
version: '3.1'
|
140
154
|
- !ruby/object:Gem::Dependency
|
141
|
-
name:
|
155
|
+
name: rails
|
142
156
|
requirement: !ruby/object:Gem::Requirement
|
143
157
|
requirements:
|
144
|
-
- -
|
158
|
+
- - ">="
|
145
159
|
- !ruby/object:Gem::Version
|
146
160
|
version: '3.2'
|
147
161
|
type: :development
|
148
162
|
prerelease: false
|
149
163
|
version_requirements: !ruby/object:Gem::Requirement
|
150
164
|
requirements:
|
151
|
-
- -
|
165
|
+
- - ">="
|
152
166
|
- !ruby/object:Gem::Version
|
153
167
|
version: '3.2'
|
154
168
|
- !ruby/object:Gem::Dependency
|
155
169
|
name: pg
|
156
170
|
requirement: !ruby/object:Gem::Requirement
|
157
171
|
requirements:
|
158
|
-
- - ~>
|
172
|
+
- - "~>"
|
159
173
|
- !ruby/object:Gem::Version
|
160
174
|
version: '0.18'
|
161
175
|
type: :development
|
162
176
|
prerelease: false
|
163
177
|
version_requirements: !ruby/object:Gem::Requirement
|
164
178
|
requirements:
|
165
|
-
- - ~>
|
179
|
+
- - "~>"
|
166
180
|
- !ruby/object:Gem::Version
|
167
181
|
version: '0.18'
|
168
182
|
- !ruby/object:Gem::Dependency
|
169
183
|
name: mysql2
|
170
184
|
requirement: !ruby/object:Gem::Requirement
|
171
185
|
requirements:
|
172
|
-
- - ~>
|
186
|
+
- - "~>"
|
173
187
|
- !ruby/object:Gem::Version
|
174
188
|
version: '0.3'
|
175
189
|
type: :development
|
176
190
|
prerelease: false
|
177
191
|
version_requirements: !ruby/object:Gem::Requirement
|
178
192
|
requirements:
|
179
|
-
- - ~>
|
193
|
+
- - "~>"
|
180
194
|
- !ruby/object:Gem::Version
|
181
195
|
version: '0.3'
|
182
196
|
- !ruby/object:Gem::Dependency
|
183
197
|
name: ammeter
|
184
198
|
requirement: !ruby/object:Gem::Requirement
|
185
199
|
requirements:
|
186
|
-
- - ~>
|
200
|
+
- - "~>"
|
187
201
|
- !ruby/object:Gem::Version
|
188
202
|
version: '1.1'
|
189
203
|
type: :development
|
190
204
|
prerelease: false
|
191
205
|
version_requirements: !ruby/object:Gem::Requirement
|
192
206
|
requirements:
|
193
|
-
- - ~>
|
207
|
+
- - "~>"
|
194
208
|
- !ruby/object:Gem::Version
|
195
209
|
version: '1.1'
|
196
210
|
description: A statesmanlike state machine library
|
@@ -200,9 +214,9 @@ executables: []
|
|
200
214
|
extensions: []
|
201
215
|
extra_rdoc_files: []
|
202
216
|
files:
|
203
|
-
- .gitignore
|
204
|
-
- .rubocop.yml
|
205
|
-
- .travis.yml
|
217
|
+
- ".gitignore"
|
218
|
+
- ".rubocop.yml"
|
219
|
+
- ".travis.yml"
|
206
220
|
- CHANGELOG.md
|
207
221
|
- CONTRIBUTING.md
|
208
222
|
- Gemfile
|
@@ -274,17 +288,17 @@ require_paths:
|
|
274
288
|
- lib
|
275
289
|
required_ruby_version: !ruby/object:Gem::Requirement
|
276
290
|
requirements:
|
277
|
-
- -
|
291
|
+
- - ">="
|
278
292
|
- !ruby/object:Gem::Version
|
279
293
|
version: '0'
|
280
294
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
281
295
|
requirements:
|
282
|
-
- -
|
296
|
+
- - ">="
|
283
297
|
- !ruby/object:Gem::Version
|
284
298
|
version: '0'
|
285
299
|
requirements: []
|
286
300
|
rubyforge_project:
|
287
|
-
rubygems_version: 2.
|
301
|
+
rubygems_version: 2.4.1
|
288
302
|
signing_key:
|
289
303
|
specification_version: 4
|
290
304
|
summary: A statesmanlike state machine library
|
@@ -312,3 +326,4 @@ test_files:
|
|
312
326
|
- spec/support/active_record.rb
|
313
327
|
- spec/support/generators_shared_examples.rb
|
314
328
|
- spec/support/mongoid.rb
|
329
|
+
has_rdoc:
|