spree-state_machine 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.travis.yml +12 -0
  4. data/.yardopts +5 -0
  5. data/CHANGELOG.md +502 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE +20 -0
  8. data/README.md +1246 -0
  9. data/Rakefile +20 -0
  10. data/examples/AutoShop_state.png +0 -0
  11. data/examples/Car_state.png +0 -0
  12. data/examples/Gemfile +5 -0
  13. data/examples/Gemfile.lock +14 -0
  14. data/examples/TrafficLight_state.png +0 -0
  15. data/examples/Vehicle_state.png +0 -0
  16. data/examples/auto_shop.rb +13 -0
  17. data/examples/car.rb +21 -0
  18. data/examples/doc/AutoShop.html +2856 -0
  19. data/examples/doc/AutoShop_state.png +0 -0
  20. data/examples/doc/Car.html +919 -0
  21. data/examples/doc/Car_state.png +0 -0
  22. data/examples/doc/TrafficLight.html +2230 -0
  23. data/examples/doc/TrafficLight_state.png +0 -0
  24. data/examples/doc/Vehicle.html +7921 -0
  25. data/examples/doc/Vehicle_state.png +0 -0
  26. data/examples/doc/_index.html +136 -0
  27. data/examples/doc/class_list.html +47 -0
  28. data/examples/doc/css/common.css +1 -0
  29. data/examples/doc/css/full_list.css +55 -0
  30. data/examples/doc/css/style.css +322 -0
  31. data/examples/doc/file_list.html +46 -0
  32. data/examples/doc/frames.html +13 -0
  33. data/examples/doc/index.html +136 -0
  34. data/examples/doc/js/app.js +205 -0
  35. data/examples/doc/js/full_list.js +173 -0
  36. data/examples/doc/js/jquery.js +16 -0
  37. data/examples/doc/method_list.html +734 -0
  38. data/examples/doc/top-level-namespace.html +105 -0
  39. data/examples/merb-rest/controller.rb +51 -0
  40. data/examples/merb-rest/model.rb +28 -0
  41. data/examples/merb-rest/view_edit.html.erb +24 -0
  42. data/examples/merb-rest/view_index.html.erb +23 -0
  43. data/examples/merb-rest/view_new.html.erb +13 -0
  44. data/examples/merb-rest/view_show.html.erb +17 -0
  45. data/examples/rails-rest/controller.rb +43 -0
  46. data/examples/rails-rest/migration.rb +7 -0
  47. data/examples/rails-rest/model.rb +23 -0
  48. data/examples/rails-rest/view__form.html.erb +34 -0
  49. data/examples/rails-rest/view_edit.html.erb +6 -0
  50. data/examples/rails-rest/view_index.html.erb +25 -0
  51. data/examples/rails-rest/view_new.html.erb +5 -0
  52. data/examples/rails-rest/view_show.html.erb +19 -0
  53. data/examples/traffic_light.rb +9 -0
  54. data/examples/vehicle.rb +33 -0
  55. data/lib/state_machine/assertions.rb +36 -0
  56. data/lib/state_machine/branch.rb +225 -0
  57. data/lib/state_machine/callback.rb +236 -0
  58. data/lib/state_machine/core.rb +7 -0
  59. data/lib/state_machine/core_ext/class/state_machine.rb +5 -0
  60. data/lib/state_machine/core_ext.rb +2 -0
  61. data/lib/state_machine/error.rb +13 -0
  62. data/lib/state_machine/eval_helpers.rb +87 -0
  63. data/lib/state_machine/event.rb +257 -0
  64. data/lib/state_machine/event_collection.rb +141 -0
  65. data/lib/state_machine/extensions.rb +149 -0
  66. data/lib/state_machine/graph.rb +92 -0
  67. data/lib/state_machine/helper_module.rb +17 -0
  68. data/lib/state_machine/initializers/rails.rb +25 -0
  69. data/lib/state_machine/initializers.rb +4 -0
  70. data/lib/state_machine/integrations/active_model/locale.rb +11 -0
  71. data/lib/state_machine/integrations/active_model/observer.rb +33 -0
  72. data/lib/state_machine/integrations/active_model/observer_update.rb +42 -0
  73. data/lib/state_machine/integrations/active_model/versions.rb +31 -0
  74. data/lib/state_machine/integrations/active_model.rb +585 -0
  75. data/lib/state_machine/integrations/active_record/locale.rb +20 -0
  76. data/lib/state_machine/integrations/active_record/versions.rb +123 -0
  77. data/lib/state_machine/integrations/active_record.rb +525 -0
  78. data/lib/state_machine/integrations/base.rb +100 -0
  79. data/lib/state_machine/integrations.rb +121 -0
  80. data/lib/state_machine/machine.rb +2287 -0
  81. data/lib/state_machine/machine_collection.rb +74 -0
  82. data/lib/state_machine/macro_methods.rb +522 -0
  83. data/lib/state_machine/matcher.rb +123 -0
  84. data/lib/state_machine/matcher_helpers.rb +54 -0
  85. data/lib/state_machine/node_collection.rb +222 -0
  86. data/lib/state_machine/path.rb +120 -0
  87. data/lib/state_machine/path_collection.rb +90 -0
  88. data/lib/state_machine/state.rb +297 -0
  89. data/lib/state_machine/state_collection.rb +112 -0
  90. data/lib/state_machine/state_context.rb +138 -0
  91. data/lib/state_machine/transition.rb +470 -0
  92. data/lib/state_machine/transition_collection.rb +245 -0
  93. data/lib/state_machine/version.rb +3 -0
  94. data/lib/state_machine/yard/handlers/base.rb +32 -0
  95. data/lib/state_machine/yard/handlers/event.rb +25 -0
  96. data/lib/state_machine/yard/handlers/machine.rb +344 -0
  97. data/lib/state_machine/yard/handlers/state.rb +25 -0
  98. data/lib/state_machine/yard/handlers/transition.rb +47 -0
  99. data/lib/state_machine/yard/handlers.rb +12 -0
  100. data/lib/state_machine/yard/templates/default/class/html/setup.rb +30 -0
  101. data/lib/state_machine/yard/templates/default/class/html/state_machines.erb +12 -0
  102. data/lib/state_machine/yard/templates.rb +3 -0
  103. data/lib/state_machine/yard.rb +8 -0
  104. data/lib/state_machine.rb +8 -0
  105. data/lib/yard-state_machine.rb +2 -0
  106. data/state_machine.gemspec +22 -0
  107. data/test/files/en.yml +17 -0
  108. data/test/files/switch.rb +15 -0
  109. data/test/functional/state_machine_test.rb +1066 -0
  110. data/test/test_helper.rb +7 -0
  111. data/test/unit/assertions_test.rb +40 -0
  112. data/test/unit/branch_test.rb +969 -0
  113. data/test/unit/callback_test.rb +704 -0
  114. data/test/unit/error_test.rb +43 -0
  115. data/test/unit/eval_helpers_test.rb +270 -0
  116. data/test/unit/event_collection_test.rb +398 -0
  117. data/test/unit/event_test.rb +1196 -0
  118. data/test/unit/graph_test.rb +98 -0
  119. data/test/unit/helper_module_test.rb +17 -0
  120. data/test/unit/integrations/active_model_test.rb +1245 -0
  121. data/test/unit/integrations/active_record_test.rb +2551 -0
  122. data/test/unit/integrations/base_test.rb +104 -0
  123. data/test/unit/integrations_test.rb +71 -0
  124. data/test/unit/invalid_event_test.rb +20 -0
  125. data/test/unit/invalid_parallel_transition_test.rb +18 -0
  126. data/test/unit/invalid_transition_test.rb +115 -0
  127. data/test/unit/machine_collection_test.rb +603 -0
  128. data/test/unit/machine_test.rb +3395 -0
  129. data/test/unit/matcher_helpers_test.rb +37 -0
  130. data/test/unit/matcher_test.rb +155 -0
  131. data/test/unit/node_collection_test.rb +362 -0
  132. data/test/unit/path_collection_test.rb +266 -0
  133. data/test/unit/path_test.rb +485 -0
  134. data/test/unit/state_collection_test.rb +352 -0
  135. data/test/unit/state_context_test.rb +441 -0
  136. data/test/unit/state_machine_test.rb +31 -0
  137. data/test/unit/state_test.rb +1101 -0
  138. data/test/unit/transition_collection_test.rb +2168 -0
  139. data/test/unit/transition_test.rb +1558 -0
  140. metadata +264 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 47e8cee5cb338748d42b5226c5ca16644b709fa4
4
+ data.tar.gz: 2b8d255d63a0c16bfaed0bf1ba4c81bfd660c430
5
+ SHA512:
6
+ metadata.gz: 8180a3c85469f82ded79279da4a60d544ca0d1a87d8fcb027d54ddd640c003c58abace449d82f7a91662ba941b634e7850d6df7d6d28620d57673a031e75a4ff
7
+ data.tar.gz: 97be6d3ce6a00cb19ca413be71825301e0b90a9eab46655a50b538dc317f52a7ca8221301739cac608200ced2e2f528bef46f07c3bed11ddd2674663a83cb40f
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ *.gem
2
+ .bundle/
3
+ .rbx/
4
+ .yardoc/
5
+ coverage/
6
+ /doc/
7
+ test/*.log
8
+ /Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ script: "bundle exec rake"
3
+ rvm:
4
+ - 2.0
5
+ - 2.1
6
+ - 2.2
7
+ env:
8
+ - INTEGRATION=default
9
+ - INTEGRATION=active_model
10
+ - INTEGRATION=active_record
11
+ notifications:
12
+ disabled: true
data/.yardopts ADDED
@@ -0,0 +1,5 @@
1
+ --title "state_machine"
2
+ --readme README.md
3
+ -
4
+ CHANGELOG.md
5
+ LICENSE
data/CHANGELOG.md ADDED
@@ -0,0 +1,502 @@
1
+ # master
2
+
3
+ * Raise InvalidContext error when the current state does not define a state-driven behavior
4
+ * Fix target state being indeterminate for transitions that use blacklists
5
+ * Allow super to be called within state-driven behaviors
6
+
7
+ ## 1.2.0 / 2013-03-30
8
+
9
+ * Allow multiple whitelisted / blacklisted :to states when definining transitions
10
+ * Fix event attributes not being processed when saved via association autosaving
11
+ * Fix Mongoid integration not setting initial state attributes properly for associations
12
+ * Completely rewrite ORM action hooks to behave more consistently across the board
13
+ * Change transitions to be executed the same whether using ORM save actions or not
14
+ * Fix around_transition callbacks not being executed properly in ORM integrations
15
+ * Fix additional transitions not being able to be fired in transition callbacks
16
+ * Add documentation on the order in which transition callbacks run within ORM integrations
17
+ * Update README to include a topic on explicit vs. implicit event transitions [Nathan Long]
18
+ * Fix around_transition pausing not being marked as unsupported for rubinius [Daniel Huckstep]
19
+ * Fix all / any / same matchers not being able to be used in :from / :to options in transitions and callbacks
20
+ * Fix ActiveModel locale paths not being loaded properly under certain JRuby environments [Brad Heller]
21
+ * Remove dependency on the validation_class_methods plugin for Sequel 2.12.0+ [Casey Howard]
22
+ * Remove dependency on command-line git binaries from within the gemspec
23
+ * Fix deprecation warnings on ruby-graphviz 1.0.3+
24
+ * Update minimum required ruby-graphviz version to 0.9.17
25
+ * Fix aliased fields in Mongoid 2.4.0+ not being automatically detected
26
+ * Add Mongoid 3.0.0+ support
27
+ * Fix scopes getting generated multiple times when the singular / plural machine names are the same but of a different type (symbol vs. string)
28
+ * Add initial support for ActiveRecord / ActiveModel 4.0.0 beta
29
+ * Fix static initial states always being set even when the state has already been initialized in non-ORM integrations
30
+ * Generate a warning when the ORM's backend and state_machine define conflicting initial states for an attribute
31
+ * Fix all Ruby warnings
32
+ * Fix callbacks not working for methods that respond via method_missing [Balwant Kane]
33
+ * Fix observer callbacks being run when disabled in ActiveModel / ActiveRecord integrations
34
+ * Add YARD integration for autogenerating documentation / embedding visualizations of state machines
35
+ * Allow states / events to be drawn with their human name instead of their internal name
36
+
37
+ ## 1.1.2 / 2012-01-20
38
+
39
+ * Fix states not being initialized properly on ActiveRecord 3.2+
40
+
41
+ ## 1.1.1 / 2011-12-31
42
+
43
+ * Fix fields being defined for Mongoid / MongoMapper state attributes even if they're already defined in the model
44
+ * Raise error when states / events are referenced in a definition with different types (e.g. both Strings and Symbols)
45
+ * Allow all states / events to be looked up by their string / symbol equivalent
46
+ * Allow state_machine to be loaded without extensions to the Ruby core
47
+
48
+ ## 1.1.0 / 2011-11-13
49
+
50
+ * Allow the transitions / known states for an event to be reset
51
+ * Add fire_#{name}_event instance method for firing an arbitrary event on a state machine
52
+ * Improve InvalidTransition exception messages to include the failure reason(s) in ORM integrations
53
+ * Don't allow around_transitions to attempt to be called in multiple execution contexts when run in jruby
54
+ * Allow :from option to be used in transitions defined within state contexts
55
+ * Fix arguments / block not being preserved when chaining methods defined in state contexts
56
+ * Fix super not being allowed when a method is defined for multiple state contexts
57
+ * Change loopbacks to only cause objects to be persisted when the ORM decides it's necessary, instead of always forcing persistence
58
+ * Fix Mongoid 2.3.x integrations not initializing dynamic states in the same manner as other integrations with initialize callbacks
59
+
60
+ ## 1.0.3 / 2011-11-03
61
+
62
+ * Fix MongoMapper 0.10.0+ integrations not matching versions properly
63
+ * Update warnings for method conflicts to include instructions on how to ignore conflicts
64
+ * Fix state initialization in Mongoid 2.3.x integrations [Durran Jordan]
65
+ * Fix after_transition callbacks sometimes not running in Mongoid 2.2.x integrations
66
+ * Automatically load the plugins required in Sequel integrations
67
+ * Allow all / any matcher helpers to be used when defining states / events
68
+ * Allow states / events to be referenced by the string equivalent of their name
69
+ * Fix observer callbacks being run incorrectly when using nil states in ActiveModel-based integrations
70
+ * Remove ActiveModel Observer method chains in order to better ensure compatibility
71
+ * Update DataMapper integration for 1.2.0+ support [Markus Schirp]
72
+ * Provide access to the human state name in invalid_transition translations
73
+ * Add support for i18n keys in the form of #{i18n_scope}.state_machines.#{model_name}.states/events.#{value}
74
+ * Clarify documentation on writing to state machine attributes, using factory_girl and can_#{event} / #{event}_transition helpers
75
+ * Add documentation for dynmically generating state machines
76
+
77
+ ## 1.0.2 / 2011-08-09
78
+
79
+ * Allow transitions to be defined within a state, event, or machine context
80
+ * Use supported framework hooks for integrating Sequel 3.24.0+
81
+ * Use appraisal for testing integrations
82
+ * Improve documentation on the handling of method conflicts
83
+ * Update Mongoid integration for 2.1.0+ support
84
+ * Fix ActiveRecord machine state predicates incorrectly calling superclass implementation when using targeted attributes
85
+ * Fix error when defining states with the same name as the state's machine in ActiveRecord, MongoMapper, and Mongoid integrations
86
+ * Fix machine state predicate not calling superclass implementation if defined after machine definition
87
+ * Generate warnings when defining a helper method more than once
88
+ * Fix multiple machines not being able to target the same attribute if all possible states aren't defined in each
89
+ * Fix ActiveModel / DataMapper integrations not overriding StateMachine::Machine#after_initialize properly
90
+ * Improve documentation for overriding states and integration transactions
91
+
92
+ ## 1.0.1 / 2011-05-30
93
+
94
+ * Add the ability to ignore method conflicts for helpers
95
+ * Generate warnings for any helper, not just state helpers, that has a conflicting method defined in the class
96
+ * Fix scopes in Sequel not working if the table name contains double underscores or is not a string/symbol
97
+ * Add full support for chaining state scopes within Sequel integrations
98
+ * Fix Rails 3.1 deprecation warnings for configuring engine locales [Stefan Penner]
99
+
100
+ ## 1.0.0 / 2011-05-12
101
+
102
+ * Celebrate
103
+
104
+ ## 0.10.4 / 2011-04-14
105
+
106
+ * Fix translations not being available under certain environments in Rails applications
107
+
108
+ ## 0.10.3 / 2011-04-07
109
+
110
+ * Fix state initialization failing in ActiveRecord 3.0.2+ when using with_state scopes for the default scope
111
+
112
+ ## 0.10.2 / 2011-03-31
113
+
114
+ * Use more integrated state initialization hooks for ActiveRecord, Mongoid, and Sequel
115
+ * Remove mass-assignment filtering usage in all ORM integrations
116
+ * Only support official Mongoid 2.0.0 release and up (no more RC support)
117
+ * Fix attributes getting initialized more than once if different state machines use the same attribute
118
+ * Only initialize states if state is blank and blank is not a valid state
119
+ * Fix instance / class helpers failing when used with certain libraries (such as Thin)
120
+
121
+ ## 0.10.1 / 2011-03-22
122
+
123
+ * Fix classes with multiple state machines failing to initialize in ActiveRecord / Mongoid / Sequel integrations
124
+
125
+ ## 0.10.0 / 2011-03-19
126
+
127
+ * Support callback terminators in MongoMapper 0.9.0+
128
+ * Fix pluralization integration on DataMapper 1.0.0 and 1.1.0
129
+ * Allow transition guards to be bypassed for event / transition / path helpers
130
+ * Allow state / condition requirements to be specified for all event / transition / path helpers
131
+ * Add the ability to skip automatically initializing state machines on #initialize
132
+ * Add #{name}_paths for walking the available paths in a state machine
133
+ * Add Mongoid 2.0.0+ support
134
+ * Use around hooks to improve compatibility with other libraries in ActiveModel / ActiveRecord / MongoMapper integrations
135
+ * Add support for MassAssignmentSecurity feature in ActiveModel integrations
136
+ * Add support for more observer hooks within MongoMapper integrations
137
+ * Add i18n support for MongoMapper validation errors
138
+ * Update support for MongoMapper integration based on rails3 branch
139
+ * Fix objects not getting marked as dirty in all integrations when #{name}_event is set
140
+ * Generate warnings when conflicting state / event names are detected
141
+ * Allow fallback to generic state predicates when individual predicates are already defined in the owner class
142
+ * Replace :include_failures after_transition option with new after_failure callback
143
+ * Provide access to transition context when raising InvalidEvent / InvalidTransition exceptions
144
+
145
+ ## 0.9.4 / 2010-08-01
146
+
147
+ * Fix validation / save hooks in Sequel 3.14.0+
148
+ * Fix integration with dirty attribute tracking on DataMapper 1.0.1+
149
+ * Fix DataMapper 1.0.1+ tests producing warnings
150
+ * Fix validation error warnings in ActiveModel / ActiveRecord 3.0.0 beta5+
151
+ * Fix mass-assignment sanitization breaking in ActiveRecord 3.0.0 beta5+ [Akira Matsuda]
152
+
153
+ ## 0.9.3 / 2010-06-26
154
+
155
+ * Allow access to human state / event names in transitions and for the current state
156
+ * Use human state / event names in error messages
157
+ * Fix event names being used inconsistently in error messages
158
+ * Allow access to the humanized version of state / event names via human_state_name / human_state_event_name
159
+ * Allow MongoMapper 0.8.0+ scopes to be chainable
160
+ * Fix i18n deprecation warnings in ActiveModel / ActiveRecord 3.0.0.beta4
161
+ * Fix default error message translations overriding existing locales in ActiveModel / ActiveRecord
162
+
163
+ ## 0.9.2 / 2010-05-24
164
+
165
+ * Fix MongoMapper integration failing in Ruby 1.9.2
166
+ * Fix Rakefile not loading in Ruby 1.9.2 [Andrea Longhi]
167
+ * Fix nil / false :integration configuration not being respected
168
+
169
+ ## 0.9.1 / 2010-05-02
170
+
171
+ * Fix ActiveRecord 2.0.0 - 2.2.3 integrations failing if version info isn't already loaded
172
+ * Fix integration with dirty attribute tracking on DataMapper 0.10.3
173
+ * Fix observers failing in ActiveRecord 3.0.0.beta4+ integrations
174
+ * Fix deprecation warning in Rails 3 railtie [Chris Yuan]
175
+
176
+ ## 0.9.0 / 2010-04-12
177
+
178
+ * Use attribute-based event transitions whenever possible to ensure consistency
179
+ * Fix action helpers being defined when the action is **only** defined in the machine's owner class
180
+ * Disable attribute-based event transitions in DataMapper 0.9.4 - 0.9.6 when dm-validations is being used
181
+ * Add support for DataMapper 0.10.3+
182
+ * Add around_transition callbacks
183
+ * Fix transition failures during save not being handled correctly in Sequel 2.12.0+
184
+ * Fix attribute-based event transitions not hooking in properly in DataMapper 0.10.0+ and Sequel 2.12.0+
185
+ * Fix dynamic initial states causing errors in Ruby 1.9+ if no arguments are defined in the block
186
+ * Add MongoMapper 0.5.5+ support
187
+ * Add ActiveModel 3.0+ support for use with integrations that implement its interface
188
+ * Fix DataMapper integration failing when ActiveSupport is loaded in place of Extlib
189
+ * Add version dependencies for ruby-graphviz
190
+ * Remove app-specific rails / merb rake tasks in favor of always running state_machine:draw
191
+ * Add Rails 3 railtie for automatically loading rake tasks when installed as a gem
192
+
193
+ ## 0.8.1 / 2010-03-14
194
+
195
+ * Release gems via rake-gemcutter instead of rubyforge
196
+ * Move rake tasks to lib/tasks
197
+ * Dispatch state behavior to the superclass if it's undefined for a particular state [Sandro Turriate and Tim Pope]
198
+ * Fix state / event names not supporting i18n in ActiveRecord
199
+ * Fix original ActiveRecord::Observer#update not being used for non-state_machine callbacks [Jeremy Wells]
200
+ * Add support for ActiveRecord 3.0
201
+ * Fix without_{name} scopes not quoting columns in ActiveRecord [Jon Evans]
202
+ * Fix without_{name} scopes not scoping columns to the table in ActiveRecord and Sequel [Jon Evans]
203
+ * Fix custom state attributes not being marked properly as changed in ActiveRecord
204
+ * Fix tracked attributes changes in ActiveRecord / DataMapper integrations not working correctly for non-loopbacks [Joe Lind]
205
+ * Fix plural scope names being incorrect for DataMapper 0.9.4 - 0.9.6
206
+ * Fix deprecation warnings for ruby-graphviz 0.9.0+
207
+ * Add support for ActiveRecord 2.0.*
208
+ * Fix nil states being overwritten when they're explicitly set in ORM integrations
209
+ * Fix default states not getting set in ORM integrations if the column has a default
210
+ * Fix event transitions being kept around while running actions/callbacks, sometimes preventing object marshalling
211
+
212
+ ## 0.8.0 / 2009-08-15
213
+
214
+ * Add support for DataMapper 0.10.0
215
+ * Always interpet nil return values from actions as failed attempts
216
+ * Fix loopbacks not causing records to save in ORM integrations if no other fields were changed
217
+ * Fix events not failing with useful errors when an object's state is invalid
218
+ * Use more friendly NoMethodError messages for state-driven behaviors
219
+ * Fix before_transition callbacks getting run twice when using event attributes in ORM integrations
220
+ * Add the ability to query for the availability of specific transitions on an object
221
+ * Allow after_transition callbacks to be explicitly run on failed attempts
222
+ * By default, don't run after_transition callbacks on failed attempts
223
+ * Fix not allowing multiple methods to be specified as arguments in callbacks
224
+ * Fix initial states being set when loading records from the database in Sequel integration
225
+ * Allow static initial states to be set earlier in the initialization of an object
226
+ * Use friendly validation errors for nil states
227
+ * Fix states not being validated properly when using custom names in ActiveRecord / DataMapper integrations
228
+
229
+ ## 0.7.6 / 2009-06-17
230
+
231
+ * Allow multiple state machines on the same class to target the same attribute
232
+ * Add support for :attribute to customize the attribute target, assuming the name is the first argument of #state_machine
233
+ * Simplify reading from / writing to machine-related attributes on objects
234
+ * Fix locale for ActiveRecord getting added to the i18n load path multiple times [Reiner Dieterich]
235
+ * Fix callbacks, guards, and state-driven behaviors not always working on tainted classes [Brandon Dimcheff]
236
+ * Use Ruby 1.9's built-in Object#instance_exec for bound callbacks when it's available
237
+ * Improve performance of cached dynamic state lookups by 25%
238
+
239
+ ## 0.7.5 / 2009-05-25
240
+
241
+ * Add built-in caching for dynamic state values when the value only needs to be generated once
242
+ * Fix flawed example for using record ids as state values
243
+ * Don't evaluate state values until they're actually used in an object instance
244
+ * Make it easier to use event attributes for actions defined in the same class as the state machine
245
+ * Fix #save/save! running transitions in ActiveRecord integrations even when a machine's action is not :save
246
+
247
+ ## 0.7.4 / 2009-05-23
248
+
249
+ * Fix #save! not firing event attributes properly in ActiveRecord integrations
250
+ * Fix log files being included in gems
251
+
252
+ ## 0.7.3 / 2009-04-25
253
+
254
+ * Require DataMapper version be >= 0.9.4
255
+ * Explicitly load Sequel's built-in inflector (>= 2.12.0) for scope names
256
+ * Don't use qualified name for event attributes
257
+ * Fix #valid? being defined for DataMapper resources when dm-validations isn't loaded
258
+ * Add auto-validation of values allowed for the state attribute in ORM integrations
259
+
260
+ ## 0.7.2 / 2009-04-08
261
+
262
+ * Add support for running multiple methods in a callback without using blocks
263
+ * Add more flexibility around how callbacks are defined
264
+ * Add security documentation around mass-assignment in ORM integrations
265
+ * Fix event attribute transitions being publicly accessible
266
+
267
+ ## 0.7.1 / 2009-04-05
268
+
269
+ * Fix machines failing to generate graphs when run from Merb tasks
270
+
271
+ ## 0.7.0 / 2009-04-04
272
+
273
+ * Add #{attribute}_event for automatically firing events when the object's action is called
274
+ * Make it easier to override state-driven behaviors
275
+ * Rollback state changes when the action fails during transitions
276
+ * Use :messages instead of :invalid_message for customizing validation errors
277
+ * Use more human-readable validation errors
278
+ * Add support for more ActiveRecord observer hooks
279
+ * Add support for targeting multiple specific state machines in DataMapper observer hooks
280
+ * Don't pass the result of the action as an argument to callbacks (access via Transition#result)
281
+ * Fix incorrect results being used when running transitions in parallel
282
+ * Fix transition args not being set when run in parallel
283
+ * Allow callback terminators to be set on an application-wide basis
284
+ * Only catch :halt during before / after transition callbacks
285
+ * Fix ActiveRecord predicates being overwritten if they're already defined in the class
286
+ * Allow machine options to be set on an integration-wide basis
287
+ * Turn transactions off by default in DataMapper integrations
288
+ * Add support for configuring the use of transactions
289
+ * Simplify reading/writing of attributes
290
+ * Simplify access to state machines via #state_machine(:attribute) without generating dupes
291
+ * Fix assumptions that dm-validations is always available in DataMapper integration
292
+ * Automatically define DataMapper properties for machine attributes if they don't exist
293
+ * Add Transition#qualified_event, #qualified_from_name, and #qualified_to_name
294
+ * Add #fire_events / #fire_events! for running events on multiple state machines in parallel
295
+ * Rename next_#{event}_transition to #{event}_transition
296
+ * Add #{attribute}_transitions for getting the list of transitions that can be run on an object
297
+ * Add #{attribute}_events for getting the list of events that can be fired on an object
298
+ * Use generated non-bang event when running bang version so that overriding one affects the other
299
+ * Provide access to arguments passed into an event from transition callbacks via Transition#args
300
+
301
+ ## 0.6.3 / 2009-03-10
302
+
303
+ * Add support for customizing the graph's orientation
304
+ * Use the standard visualizations for initial (open arrow) and final (double circle) states
305
+ * Highlight final states in GraphViz drawings
306
+
307
+ ## 0.6.2 / 2009-03-08
308
+
309
+ * Make it easier to override generated instance / class methods
310
+
311
+ ## 0.6.1 / 2009-03-07
312
+
313
+ * Add i18n support for ActiveRecord validation errors
314
+ * Add a validation error when failing to transition for ActiveRecord / DataMapper / Sequel integrations
315
+
316
+ ## 0.6.0 / 2009-03-03
317
+
318
+ * Allow multiple conditions for callbacks / class behaviors
319
+ * Add support for state-driven class behavior with :if/:unless options
320
+ * Alias Machine#event as Machine#on
321
+ * Fix nil from/to states not being handled properly
322
+ * Simplify hooking callbacks into loopbacks
323
+ * Add simplified transition/callback requirement syntax
324
+
325
+ ## 0.5.2 / 2009-02-17
326
+
327
+ * Improve pretty-print of events
328
+ * Simplify state/event matching design, improving guard performance by 30%
329
+ * Add better error notification when conflicting guard options are defined
330
+ * Fix scope name pluralization not being applied correctly
331
+
332
+ ## 0.5.1 / 2009-02-11
333
+
334
+ * Allow states to be drawn as ellipses to accommodate long names
335
+ * Fix rake tasks not being registered in Rails/Merb applications
336
+ * Never automatically define machine attribute accessors when using an integration
337
+
338
+ ## 0.5.0 / 2009-01-11
339
+
340
+ * Add to_name and from_name to transition objects
341
+ * Add nicely formatted #inspect for transitions
342
+ * Fix ActiveRecord integrations failing when the database doesn't exist yet
343
+ * Fix states not being drawn in GraphViz graphs in the correct order
344
+ * Add nicely formatted #inspect for states and events
345
+ * Simplify machine context-switching
346
+ * Store events/states in enumerable node collections
347
+ * No longer allow subclasses to change the integration
348
+ * Move fire! action logic into the Event class (no longer calls fire action on the object)
349
+ * Allow states in subclasses to have different values
350
+ * Recommend that all states be referenced as symbols instead of strings
351
+ * All states must now be named (and can be associated with other value types)
352
+ * Add support for customizing the actual stored value for a state
353
+ * Add compatibility with Ruby 1.9+
354
+
355
+ ## 0.4.3 / 2008-12-28
356
+
357
+ * Allow dm-observer integration to be optional
358
+ * Fix non-lambda callbacks not working for DataMapper/Sequel
359
+
360
+ ## 0.4.2 / 2008-12-28
361
+
362
+ * Fix graphs not being drawn the same way consistently
363
+ * Add support for sharing transitions across multiple events
364
+ * Add support for state-driven behavior
365
+ * Simplify initialize hooks, requiring super to be called instead
366
+ * Add :namespace option for generated state predicates / event methods
367
+
368
+ ## 0.4.1 / 2008-12-16
369
+
370
+ * Fix nil states not being handled properly in guards, known states, or visualizations
371
+ * Fix the same node being used for different dynamic states in GraphViz output
372
+ * Always include initial state in the list of known states even if it's dynamic
373
+ * Use consistent naming scheme for dynamic states in GraphViz output
374
+ * Allow blocks to be directly passed into machine class
375
+ * Fix attribute predicates not working on attributes that represent columns in ActiveRecord
376
+
377
+ ## 0.4.0 / 2008-12-14
378
+
379
+ * Remove the PluginAWeek namespace
380
+ * Add generic attribute predicate (e.g. "#{attribute}?(state_name)") and state predicates (e.g. "#{state}?")
381
+ * Add Sequel support
382
+ * Fix aliasing :initialize on ActiveRecord models causing warnings when the environment is reloaded
383
+ * Fix ActiveRecord state machines trying to query the database on unmigrated models
384
+ * Fix initial states not getting set when the current value is an empty string [Aaron Gibralter]
385
+ * Add rake tasks for generating graphviz files for state machines [Nate Murray]
386
+ * Fix initial state not being included in list of known states
387
+ * Add other_states directive for defining additional states not referenced in transitions or callbacks [Pete Forde]
388
+ * Add next_#{event}_transition for getting the next transition that would be performed if the event were invoked
389
+ * Add the ability to override the pluralized name of an attribute for creating scopes
390
+ * Add the ability to halt callback chains by: throw :halt
391
+ * Add support for dynamic to states in transitions (e.g. :to => lambda {Time.now})
392
+ * Add support for using real blocks in before_transition/after_transition calls instead of using the :do option
393
+ * Add DataMapper support
394
+ * Include states referenced in transition callbacks in the list of a machine's known states
395
+ * Only generate the known states for a machine on demand, rather than calculating beforehand
396
+ * Add the ability to skip state change actions during a transition (e.g. vehicle.ignite(false))
397
+ * Add the ability for the state change action (e.g. `save` for ActiveRecord) to be configurable
398
+ * Allow state machines to be defined on **any** Ruby class, not just ActiveRecord (removes all external dependencies)
399
+ * Refactor transitions, guards, and callbacks for better organization/design
400
+ * Use a class containing the transition context in callbacks, rather than an ordered list of each individual attribute
401
+ * Add without_#{attribute} named scopes (opposite of the existing with_#{attribute} named scopes) [Sean O'Brien]
402
+
403
+ ## 0.3.1 / 2008-10-26
404
+
405
+ * Fix the initial state not getting set when the state attribute is mass-assigned but protected
406
+ * Change how the base module is included to prevent namespacing conflicts
407
+
408
+ ## 0.3.0 / 2008-09-07
409
+
410
+ * No longer allow additional arguments to be passed into event actions
411
+ * Add support for can_#{event}? for checking whether an event can be fired based on the current state of the record
412
+ * Don't use callbacks for performing transitions
413
+ * Fix state machines in subclasses not knowing what states/events/transitions were defined by superclasses
414
+ * Replace all before/after_exit/enter/loopback callback hooks and :before/:after options for events with before_transition/after_transition callbacks, e.g.
415
+
416
+ before_transition :from => 'parked', :do => :lock_doors # was before_exit :parked, :lock_doors
417
+ after_transition :on => 'ignite', :do => :turn_on_radio # was event :ignite, :after => :turn_on_radio do
418
+
419
+ * Always save when an event is fired even if it results in a loopback [Jürgen Strobel]
420
+ * Ensure initial state callbacks are invoked in the proper order when an event is fired on a new record
421
+ * Add before_loopback and after_loopback hooks [Jürgen Strobel]
422
+
423
+ ## 0.2.1 / 2008-07-05
424
+
425
+ * Add more descriptive exceptions
426
+ * Assume the default state attribute is "state" if one is not provided
427
+ * Add :except_from option for transitions if you want to blacklist states
428
+ * Add PluginAWeek::StateMachine::Machine#states
429
+ * Add PluginAWeek::StateMachine::Event#transitions
430
+ * Allow creating transitions with no from state (effectively allowing the transition for **any** from state)
431
+ * Reduce the number of objects created for each transition
432
+
433
+ ## 0.2.0 / 2008-06-29
434
+
435
+ * Add a non-bang version of events (e.g. park) that will return a boolean value for success
436
+ * Raise an exception if the bang version of events are used (e.g. park!) and no transition is successful
437
+ * Change callbacks to act a little more like ActiveRecord
438
+ * Avoid using string evaluation for dynamic methods
439
+
440
+ ## 0.1.1 / 2008-06-22
441
+
442
+ * Remove log files from gems
443
+
444
+ ## 0.1.0 / 2008-05-05
445
+
446
+ * Completely rewritten from scratch
447
+ * Renamed to state_machine
448
+ * Removed database dependencies
449
+ * Removed models in favor of an attribute-agnostic design
450
+ * Use ActiveSupport::Callbacks instead of eval_call
451
+ * Remove dry_transaction_rollbacks dependencies
452
+ * Added functional tests
453
+ * Updated documentation
454
+
455
+ ## 0.0.1 / 2007-09-26
456
+
457
+ * Add dependency on custom_callbacks
458
+ * Move test fixtures out of the test application root directory
459
+ * Improve documentation
460
+ * Remove the StateExtension module in favor of adding singleton methods to the stateful class
461
+ * Convert dos newlines to unix newlines
462
+ * Fix error message when a given event can't be found in the database
463
+ * Add before_#{action} and #{action} callbacks when an event is performed
464
+ * All state and event callbacks can now explicitly return false in order to cancel the action
465
+ * Refactor ActiveState callback creation
466
+ * Refactor unit tests so that they use mock classes instead of themselves
467
+ * Allow force_reload option to be set in the state association
468
+ * Don't save the entire model when updating the state_id
469
+ * Raise exception if a class tries to define a state more than once
470
+ * Add tests for PluginAWeek::Has::States::ActiveState
471
+ * Refactor active state/active event creation
472
+ * Fix owner_type not being set correctly in active states/events of subclasses
473
+ * Allow subclasses to override the initial state
474
+ * Fix problem with migrations using default null when column cannot be null
475
+ * Moved deadline support into a separate plugin (has_state_deadlines).
476
+ * Added many more unit tests.
477
+ * Simplified many of the interfaces for maintainability.
478
+ * Added support for turning off recording state changes.
479
+ * Removed the short_description and long_description columns, in favor of an optional human_name column.
480
+ * Fixed not overriding the correct equality methods in the StateTransition class.
481
+ * Added to_sym to State and Event.
482
+ * State#name and Event#name now return the string version of the name instead of the symbol version.
483
+ * Added State#human_name and Event#human_name to automatically figure out what the human name is if it isn't specified in the table.
484
+ * Updated manual rollbacks to use the new Rails edge api (ActiveRecord::Rollback exception).
485
+ * Moved StateExtension class into a separate file in order to help keep the has_state files clean.
486
+ * Renamed InvalidState and InvalidEvent exceptions to StateNotFound and EventNotFound in order to follow the ActiveRecord convention (i.e. RecordNotFound).
487
+ * Added StateNotActive and EventNotActive exceptions to help differentiate between states which don't exist and states which weren't defined in the class.
488
+ * Added support for defining callbacks like so:
489
+
490
+ def before_exit_parked
491
+ end
492
+
493
+ def after_enter_idling
494
+ end
495
+
496
+ * Added support for defining callbacks using class methods:
497
+
498
+ before_exit_parked :fasten_seatbelt
499
+
500
+ * Added event callbacks after the transition has occurred (e.g. after_park)
501
+ * State callbacks no longer receive any of the arguments that were provided in the event action
502
+ * Updated license to include our names.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://www.rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2006-2012 Aaron Pfeifer
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.