state_machine 0.9.1 → 0.9.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.
- data/CHANGELOG.rdoc +6 -0
- data/README.rdoc +3 -1
- data/Rakefile +2 -2
- data/lib/state_machine/integrations/mongo_mapper.rb +1 -1
- data/lib/state_machine/machine.rb +7 -1
- data/test/unit/machine_test.rb +25 -4
- metadata +76 -76
data/CHANGELOG.rdoc
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
== master
|
2
2
|
|
3
|
+
== 0.9.2 / 2010-05-24
|
4
|
+
|
5
|
+
* Fix MongoMapper integration failing in Ruby 1.9.2
|
6
|
+
* Fix Rakefile not loading in Ruby 1.9.2 [Andrea Longhi]
|
7
|
+
* Fix nil / false :integration configuration not being respected
|
8
|
+
|
3
9
|
== 0.9.1 / 2010-05-02
|
4
10
|
|
5
11
|
* Fix ActiveRecord 2.0.0 - 2.2.3 integrations failing if version info isn't already loaded
|
data/README.rdoc
CHANGED
@@ -110,8 +110,10 @@ Class definition:
|
|
110
110
|
end
|
111
111
|
|
112
112
|
event :repair do
|
113
|
+
# The first transition that matches the state and passes its conditions
|
114
|
+
# will be used
|
113
115
|
transition :stalled => :parked, :if => :auto_shop_busy?
|
114
|
-
transition :stalled => same
|
116
|
+
transition :stalled => same
|
115
117
|
end
|
116
118
|
|
117
119
|
state :parked do
|
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ require 'rake/gempackagetask'
|
|
6
6
|
|
7
7
|
spec = Gem::Specification.new do |s|
|
8
8
|
s.name = 'state_machine'
|
9
|
-
s.version = '0.9.
|
9
|
+
s.version = '0.9.2'
|
10
10
|
s.platform = Gem::Platform::RUBY
|
11
11
|
s.summary = 'Adds support for creating state machines for attributes on any Ruby class'
|
12
12
|
s.description = s.summary
|
@@ -74,4 +74,4 @@ task :release => :package do
|
|
74
74
|
Rake::Task['gem:push'].invoke
|
75
75
|
end
|
76
76
|
|
77
|
-
load 'lib/tasks/state_machine.rake'
|
77
|
+
load File.dirname(__FILE__) + '/lib/tasks/state_machine.rake'
|
@@ -253,7 +253,7 @@ module StateMachine
|
|
253
253
|
owner_class.key(attribute, String) unless owner_class.keys.include?(attribute)
|
254
254
|
|
255
255
|
name = self.name
|
256
|
-
owner_class.validates_each(attribute, :logic => lambda {
|
256
|
+
owner_class.validates_each(attribute, :logic => lambda {|*|
|
257
257
|
machine = self.class.state_machine(name)
|
258
258
|
machine.invalidate(self, :state, :invalid) unless machine.states.match(self)
|
259
259
|
})
|
@@ -419,7 +419,13 @@ module StateMachine
|
|
419
419
|
assert_valid_keys(options, :attribute, :initial, :action, :plural, :namespace, :integration, :messages, :use_transactions)
|
420
420
|
|
421
421
|
# Find an integration that matches this machine's owner class
|
422
|
-
if
|
422
|
+
if options.include?(:integration)
|
423
|
+
integration = StateMachine::Integrations.find(options[:integration]) if options[:integration]
|
424
|
+
else
|
425
|
+
integration = StateMachine::Integrations.match(owner_class)
|
426
|
+
end
|
427
|
+
|
428
|
+
if integration
|
423
429
|
extend integration
|
424
430
|
options = integration.defaults.merge(options) if integration.respond_to?(:defaults)
|
425
431
|
end
|
data/test/unit/machine_test.rb
CHANGED
@@ -377,12 +377,33 @@ end
|
|
377
377
|
|
378
378
|
class MachineWithCustomIntegrationTest < Test::Unit::TestCase
|
379
379
|
def setup
|
380
|
-
|
381
|
-
|
380
|
+
integration = Module.new do
|
381
|
+
def self.matches?(klass)
|
382
|
+
true
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
StateMachine::Integrations.const_set('Custom', integration)
|
382
387
|
end
|
383
388
|
|
384
|
-
def
|
385
|
-
|
389
|
+
def test_should_be_extended_by_the_integration_if_explicit
|
390
|
+
machine = StateMachine::Machine.new(Class.new, :integration => :custom)
|
391
|
+
assert (class << machine; ancestors; end).include?(StateMachine::Integrations::Custom)
|
392
|
+
end
|
393
|
+
|
394
|
+
def test_should_be_extended_by_the_integration_if_implicit
|
395
|
+
machine = StateMachine::Machine.new(Class.new)
|
396
|
+
assert (class << machine; ancestors; end).include?(StateMachine::Integrations::Custom)
|
397
|
+
end
|
398
|
+
|
399
|
+
def test_should_not_be_extended_by_the_integration_if_nil
|
400
|
+
machine = StateMachine::Machine.new(Class.new, :integration => nil)
|
401
|
+
assert !(class << machine; ancestors; end).include?(StateMachine::Integrations::Custom)
|
402
|
+
end
|
403
|
+
|
404
|
+
def test_should_not_be_extended_by_the_integration_if_false
|
405
|
+
machine = StateMachine::Machine.new(Class.new, :integration => false)
|
406
|
+
assert !(class << machine; ancestors; end).include?(StateMachine::Integrations::Custom)
|
386
407
|
end
|
387
408
|
|
388
409
|
def teardown
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: state_machine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Pfeifer
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-05-
|
12
|
+
date: 2010-05-24 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -22,88 +22,88 @@ extensions: []
|
|
22
22
|
extra_rdoc_files: []
|
23
23
|
|
24
24
|
files:
|
25
|
-
- examples/
|
26
|
-
- examples/
|
27
|
-
- examples/TrafficLight_state.png
|
25
|
+
- examples/AutoShop_state.png
|
26
|
+
- examples/vehicle.rb
|
28
27
|
- examples/car.rb
|
29
|
-
- examples/
|
30
|
-
- examples/rails-rest/
|
31
|
-
- examples/rails-rest/
|
28
|
+
- examples/Vehicle_state.png
|
29
|
+
- examples/rails-rest/view_index.html.erb
|
30
|
+
- examples/rails-rest/view_new.html.erb
|
32
31
|
- examples/rails-rest/view_show.html.erb
|
33
32
|
- examples/rails-rest/controller.rb
|
33
|
+
- examples/rails-rest/view_edit.html.erb
|
34
|
+
- examples/rails-rest/model.rb
|
34
35
|
- examples/rails-rest/migration.rb
|
35
|
-
- examples/
|
36
|
-
- examples/
|
37
|
-
- examples/
|
38
|
-
- examples/
|
39
|
-
- examples/vehicle.rb
|
40
|
-
- examples/merb-rest/view_edit.html.erb
|
41
|
-
- examples/merb-rest/model.rb
|
36
|
+
- examples/Car_state.png
|
37
|
+
- examples/traffic_light.rb
|
38
|
+
- examples/merb-rest/view_index.html.erb
|
39
|
+
- examples/merb-rest/view_new.html.erb
|
42
40
|
- examples/merb-rest/view_show.html.erb
|
43
41
|
- examples/merb-rest/controller.rb
|
44
|
-
- examples/merb-rest/
|
45
|
-
- examples/merb-rest/
|
46
|
-
-
|
47
|
-
-
|
48
|
-
- lib/state_machine
|
42
|
+
- examples/merb-rest/view_edit.html.erb
|
43
|
+
- examples/merb-rest/model.rb
|
44
|
+
- examples/auto_shop.rb
|
45
|
+
- examples/TrafficLight_state.png
|
46
|
+
- lib/state_machine.rb
|
47
|
+
- lib/tasks/state_machine.rake
|
48
|
+
- lib/tasks/state_machine.rb
|
49
|
+
- lib/state_machine/transition.rb
|
49
50
|
- lib/state_machine/initializers/rails.rb
|
50
|
-
- lib/state_machine/
|
51
|
-
- lib/state_machine/
|
51
|
+
- lib/state_machine/initializers/merb.rb
|
52
|
+
- lib/state_machine/condition_proxy.rb
|
53
|
+
- lib/state_machine/matcher.rb
|
54
|
+
- lib/state_machine/state.rb
|
55
|
+
- lib/state_machine/assertions.rb
|
56
|
+
- lib/state_machine/integrations.rb
|
57
|
+
- lib/state_machine/eval_helpers.rb
|
58
|
+
- lib/state_machine/event_collection.rb
|
59
|
+
- lib/state_machine/matcher_helpers.rb
|
60
|
+
- lib/state_machine/guard.rb
|
52
61
|
- lib/state_machine/event.rb
|
62
|
+
- lib/state_machine/callback.rb
|
63
|
+
- lib/state_machine/machine_collection.rb
|
53
64
|
- lib/state_machine/machine.rb
|
54
|
-
- lib/state_machine/guard.rb
|
55
|
-
- lib/state_machine/assertions.rb
|
56
65
|
- lib/state_machine/transition_collection.rb
|
57
|
-
- lib/state_machine/extensions.rb
|
58
|
-
- lib/state_machine/integrations/data_mapper/observer.rb
|
59
|
-
- lib/state_machine/integrations/active_model/observer.rb
|
60
|
-
- lib/state_machine/integrations/active_model/locale.rb
|
61
|
-
- lib/state_machine/integrations/sequel.rb
|
62
|
-
- lib/state_machine/integrations/data_mapper.rb
|
63
66
|
- lib/state_machine/integrations/active_model.rb
|
64
|
-
- lib/state_machine/integrations/active_record.rb
|
65
67
|
- lib/state_machine/integrations/mongo_mapper.rb
|
68
|
+
- lib/state_machine/integrations/data_mapper.rb
|
69
|
+
- lib/state_machine/integrations/active_record.rb
|
70
|
+
- lib/state_machine/integrations/sequel.rb
|
66
71
|
- lib/state_machine/integrations/active_record/locale.rb
|
67
|
-
- lib/state_machine/
|
68
|
-
- lib/state_machine/
|
69
|
-
- lib/state_machine/
|
72
|
+
- lib/state_machine/integrations/data_mapper/observer.rb
|
73
|
+
- lib/state_machine/integrations/active_model/locale.rb
|
74
|
+
- lib/state_machine/integrations/active_model/observer.rb
|
75
|
+
- lib/state_machine/state_collection.rb
|
70
76
|
- lib/state_machine/node_collection.rb
|
71
|
-
- lib/state_machine/
|
72
|
-
- lib/state_machine/
|
73
|
-
-
|
74
|
-
- lib/state_machine/matcher.rb
|
75
|
-
- lib/state_machine/transition.rb
|
76
|
-
- lib/tasks/state_machine.rake
|
77
|
-
- lib/tasks/state_machine.rb
|
78
|
-
- lib/state_machine.rb
|
79
|
-
- test/unit/transition_collection_test.rb
|
77
|
+
- lib/state_machine/extensions.rb
|
78
|
+
- lib/state_machine/initializers.rb
|
79
|
+
- test/classes/switch.rb
|
80
80
|
- test/unit/callback_test.rb
|
81
|
-
- test/unit/state_machine_test.rb
|
82
|
-
- test/unit/invalid_event_test.rb
|
83
|
-
- test/unit/state_collection_test.rb
|
84
|
-
- test/unit/machine_collection_test.rb
|
85
|
-
- test/unit/event_test.rb
|
86
81
|
- test/unit/transition_test.rb
|
87
|
-
- test/unit/
|
82
|
+
- test/unit/machine_test.rb
|
83
|
+
- test/unit/event_test.rb
|
84
|
+
- test/unit/event_collection_test.rb
|
85
|
+
- test/unit/invalid_transition_test.rb
|
86
|
+
- test/unit/state_collection_test.rb
|
87
|
+
- test/unit/invalid_event_test.rb
|
88
|
+
- test/unit/assertions_test.rb
|
89
|
+
- test/unit/integrations_test.rb
|
90
|
+
- test/unit/transition_collection_test.rb
|
88
91
|
- test/unit/guard_test.rb
|
92
|
+
- test/unit/eval_helpers_test.rb
|
93
|
+
- test/unit/integrations/mongo_mapper_test.rb
|
89
94
|
- test/unit/integrations/data_mapper_test.rb
|
90
95
|
- test/unit/integrations/sequel_test.rb
|
91
|
-
- test/unit/integrations/mongo_mapper_test.rb
|
92
96
|
- test/unit/integrations/active_model_test.rb
|
93
97
|
- test/unit/integrations/active_record_test.rb
|
94
|
-
- test/unit/eval_helpers_test.rb
|
95
|
-
- test/unit/invalid_transition_test.rb
|
96
|
-
- test/unit/integrations_test.rb
|
97
|
-
- test/unit/state_test.rb
|
98
|
-
- test/unit/condition_proxy_test.rb
|
99
|
-
- test/unit/assertions_test.rb
|
100
|
-
- test/unit/event_collection_test.rb
|
101
|
-
- test/unit/machine_test.rb
|
102
98
|
- test/unit/matcher_test.rb
|
103
99
|
- test/unit/node_collection_test.rb
|
104
|
-
- test/
|
105
|
-
- test/
|
100
|
+
- test/unit/matcher_helpers_test.rb
|
101
|
+
- test/unit/state_test.rb
|
102
|
+
- test/unit/machine_collection_test.rb
|
103
|
+
- test/unit/state_machine_test.rb
|
104
|
+
- test/unit/condition_proxy_test.rb
|
106
105
|
- test/functional/state_machine_test.rb
|
106
|
+
- test/test_helper.rb
|
107
107
|
- CHANGELOG.rdoc
|
108
108
|
- init.rb
|
109
109
|
- LICENSE
|
@@ -138,29 +138,29 @@ signing_key:
|
|
138
138
|
specification_version: 3
|
139
139
|
summary: Adds support for creating state machines for attributes on any Ruby class
|
140
140
|
test_files:
|
141
|
-
- test/unit/transition_collection_test.rb
|
142
141
|
- test/unit/callback_test.rb
|
143
|
-
- test/unit/state_machine_test.rb
|
144
|
-
- test/unit/invalid_event_test.rb
|
145
|
-
- test/unit/state_collection_test.rb
|
146
|
-
- test/unit/machine_collection_test.rb
|
147
|
-
- test/unit/event_test.rb
|
148
142
|
- test/unit/transition_test.rb
|
149
|
-
- test/unit/
|
143
|
+
- test/unit/machine_test.rb
|
144
|
+
- test/unit/event_test.rb
|
145
|
+
- test/unit/event_collection_test.rb
|
146
|
+
- test/unit/invalid_transition_test.rb
|
147
|
+
- test/unit/state_collection_test.rb
|
148
|
+
- test/unit/invalid_event_test.rb
|
149
|
+
- test/unit/assertions_test.rb
|
150
|
+
- test/unit/integrations_test.rb
|
151
|
+
- test/unit/transition_collection_test.rb
|
150
152
|
- test/unit/guard_test.rb
|
153
|
+
- test/unit/eval_helpers_test.rb
|
154
|
+
- test/unit/integrations/mongo_mapper_test.rb
|
151
155
|
- test/unit/integrations/data_mapper_test.rb
|
152
156
|
- test/unit/integrations/sequel_test.rb
|
153
|
-
- test/unit/integrations/mongo_mapper_test.rb
|
154
157
|
- test/unit/integrations/active_model_test.rb
|
155
158
|
- test/unit/integrations/active_record_test.rb
|
156
|
-
- test/unit/eval_helpers_test.rb
|
157
|
-
- test/unit/invalid_transition_test.rb
|
158
|
-
- test/unit/integrations_test.rb
|
159
|
-
- test/unit/state_test.rb
|
160
|
-
- test/unit/condition_proxy_test.rb
|
161
|
-
- test/unit/assertions_test.rb
|
162
|
-
- test/unit/event_collection_test.rb
|
163
|
-
- test/unit/machine_test.rb
|
164
159
|
- test/unit/matcher_test.rb
|
165
160
|
- test/unit/node_collection_test.rb
|
161
|
+
- test/unit/matcher_helpers_test.rb
|
162
|
+
- test/unit/state_test.rb
|
163
|
+
- test/unit/machine_collection_test.rb
|
164
|
+
- test/unit/state_machine_test.rb
|
165
|
+
- test/unit/condition_proxy_test.rb
|
166
166
|
- test/functional/state_machine_test.rb
|