killian-aasm 2.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +33 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +74 -0
- data/Rakefile +94 -0
- data/TODO +9 -0
- data/doc/jamis.rb +591 -0
- data/lib/AASM/SupportingClasses/event.rb +54 -0
- data/lib/AASM/SupportingClasses/state.rb +33 -0
- data/lib/AASM/SupportingClasses/state_transition.rb +36 -0
- data/lib/AASM/aasm.rb +159 -0
- data/lib/AASM/persistence/active_record_persistence.rb +246 -0
- data/lib/AASM/persistence/persistence.rb +16 -0
- data/lib/AASM/state_machine.rb +35 -0
- metadata +73 -0
data/CHANGELOG
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
* In AR persistence, move state column from class level variables into the StateMachine object for the class
|
2
|
+
|
3
|
+
* allowed :to array and :on_transition callback [Kevin Triplett]
|
4
|
+
|
5
|
+
* Support enter and exit actions on states
|
6
|
+
|
7
|
+
* Use named_scope in AR persistence layer, if available [Jan De Poorter]
|
8
|
+
|
9
|
+
* Incremented version number
|
10
|
+
|
11
|
+
* Cleaned up aasm_states_for_select to return the value as a string
|
12
|
+
|
13
|
+
* Specs and bug fixes for the ActiveRecordPersistence, keeping persistence columns in sync
|
14
|
+
Allowing for nil values in states for active record
|
15
|
+
Only set state to default state before_validation_on_create
|
16
|
+
New rake task to uninstall, build and reinstall the gem (useful for development)
|
17
|
+
Changed scott's email address to protect it from spambots when publishing rdocs
|
18
|
+
New non-(!) methods that allow for firing events without persisting [Jeff Dean]
|
19
|
+
|
20
|
+
* Added aasm_states_for_select that will return a select friendly collection of states.
|
21
|
+
|
22
|
+
* Add some event callbacks, #aasm_event_fired(from, to), and #aasm_event_failed(event)
|
23
|
+
Based on transition logging suggestion [Artem Vasiliev] and timestamp column suggestion [Mike Ferrier]
|
24
|
+
|
25
|
+
* Add #aasm_events_for_state and #aasm_events_for_current_state [Joao Paulo Lins]
|
26
|
+
|
27
|
+
* Ensure that a state is written for a new record even if aasm_current_state or
|
28
|
+
{state}= are never called.
|
29
|
+
|
30
|
+
* Fix AR persistence so new records have their state set. [Joao Paulo Lins]
|
31
|
+
|
32
|
+
* Make #event! methods return a boolean [Joel Chippindale]
|
33
|
+
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Scott Barron
|
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.
|
data/README.rdoc
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
= AASM - Ruby state machines
|
2
|
+
|
3
|
+
This package contains AASM, a library for adding finite state machines to Ruby classes.
|
4
|
+
|
5
|
+
AASM started as the acts_as_state_machine plugin but has evolved into a more generic library that no longer targets only ActiveRecord models.
|
6
|
+
|
7
|
+
AASM has the following features:
|
8
|
+
|
9
|
+
* States
|
10
|
+
* Machines
|
11
|
+
* Events
|
12
|
+
* Transitions
|
13
|
+
|
14
|
+
== Download
|
15
|
+
|
16
|
+
The latest AASM can currently be pulled from the git repository on github.
|
17
|
+
|
18
|
+
* http://github.com/rubyist/aasm/tree/master
|
19
|
+
|
20
|
+
A release and a gem are forthcoming.
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
== Installation
|
25
|
+
|
26
|
+
=== From GitHub hosted gems
|
27
|
+
|
28
|
+
% sudo gem sources -a http://gems.github.com # (you only need to do this once)
|
29
|
+
% sudo gem install rubyist-aasm
|
30
|
+
|
31
|
+
=== Building your own gems
|
32
|
+
|
33
|
+
% rake gem
|
34
|
+
% sudo gem install pkg/aasm-2.0.1.gem
|
35
|
+
|
36
|
+
|
37
|
+
== Simple Example
|
38
|
+
|
39
|
+
Here's a quick example highlighting some of the features.
|
40
|
+
|
41
|
+
class Conversation
|
42
|
+
include AASM
|
43
|
+
|
44
|
+
aasm_initial_state :unread
|
45
|
+
|
46
|
+
aasm_state :unread
|
47
|
+
aasm_state :read
|
48
|
+
aasm_state :closed
|
49
|
+
|
50
|
+
|
51
|
+
aasm_event :view do
|
52
|
+
transitions :to => :read, :from => [:unread]
|
53
|
+
end
|
54
|
+
|
55
|
+
aasm_event :close do
|
56
|
+
transitions :to => :closed, :from => [:read, :unread]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
= Other Stuff
|
61
|
+
|
62
|
+
Author:: Scott Barron <scott at elitists dot net>
|
63
|
+
License:: Copyright 2006, 2007, 2008 by Scott Barron.
|
64
|
+
Released under an MIT-style license. See the LICENSE file
|
65
|
+
included in the distribution.
|
66
|
+
Bugs:: http://rubyist.lighthouseapp.com/projects/13207-aasm/
|
67
|
+
GitHub:: http://github.com/rubyist/aasm/tree/master
|
68
|
+
|
69
|
+
== Warranty
|
70
|
+
|
71
|
+
This software is provided "as is" and without any express or
|
72
|
+
implied warranties, including, without limitation, the implied
|
73
|
+
warranties of merchantibility and fitness for a particular
|
74
|
+
purpose.
|
data/Rakefile
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# Copyright 2008 Scott Barron (scott@elitists.net)
|
2
|
+
# All rights reserved
|
3
|
+
|
4
|
+
# This file may be distributed under an MIT style license.
|
5
|
+
# See MIT-LICENSE for details.
|
6
|
+
|
7
|
+
begin
|
8
|
+
require 'rubygems'
|
9
|
+
require 'rake/gempackagetask'
|
10
|
+
require 'rake/testtask'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
require 'spec/rake/spectask'
|
13
|
+
rescue Exception
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
|
17
|
+
if `ruby -Ilib -raasm -e "print AASM.Version"` =~ /([0-9.]+)$/
|
18
|
+
CURRENT_VERSION = $1
|
19
|
+
else
|
20
|
+
CURRENT_VERSION = '0.0.0'
|
21
|
+
end
|
22
|
+
$package_version = CURRENT_VERSION
|
23
|
+
|
24
|
+
PKG_FILES = FileList['[A-Z]*',
|
25
|
+
'lib/**/*.rb',
|
26
|
+
'doc/**/*'
|
27
|
+
]
|
28
|
+
|
29
|
+
desc 'Generate documentation for the acts as state machine plugin.'
|
30
|
+
rd = Rake::RDocTask.new(:rdoc) do |rdoc|
|
31
|
+
rdoc.rdoc_dir = 'html'
|
32
|
+
rdoc.template = 'doc/jamis.rb'
|
33
|
+
rdoc.rdoc_dir = 'rdoc'
|
34
|
+
rdoc.title = 'AASM'
|
35
|
+
rdoc.options << '--line-numbers' << '--inline-source' << '--main' << 'README.rdoc' << '--title' << 'AASM'
|
36
|
+
rdoc.rdoc_files.include('README.rdoc', 'MIT-LICENSE', 'TODO', 'CHANGELOG')
|
37
|
+
rdoc.rdoc_files.include('lib/**/*.rb', 'doc/**/*.rdoc')
|
38
|
+
end
|
39
|
+
|
40
|
+
if !defined?(Gem)
|
41
|
+
puts "Package target requires RubyGEMs"
|
42
|
+
else
|
43
|
+
spec = Gem::Specification.new do |s|
|
44
|
+
s.name = 'aasm'
|
45
|
+
s.version = $package_version
|
46
|
+
s.summary = 'State machine mixin for Ruby objects'
|
47
|
+
s.description = <<-EOF
|
48
|
+
AASM is a continuation of the acts as state machine rails plugin, built for plain Ruby objects.
|
49
|
+
EOF
|
50
|
+
s.files = PKG_FILES.to_a
|
51
|
+
s.require_path = 'lib'
|
52
|
+
s.has_rdoc = true
|
53
|
+
s.extra_rdoc_files = rd.rdoc_files.reject {|fn| fn =~ /\.rb$/}.to_a
|
54
|
+
s.rdoc_options = rd.options
|
55
|
+
|
56
|
+
s.author = 'Scott Barron'
|
57
|
+
s.email = 'scott@elitists.net'
|
58
|
+
s.homepage = 'http://rubyi.st/aasm'
|
59
|
+
end
|
60
|
+
|
61
|
+
package_task = Rake::GemPackageTask.new(spec) do |pkg|
|
62
|
+
pkg.need_zip = true
|
63
|
+
pkg.need_tar = true
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
if !defined?(Spec)
|
68
|
+
puts "spec and cruise targets require RSpec"
|
69
|
+
else
|
70
|
+
desc "Run all examples with RCov"
|
71
|
+
Spec::Rake::SpecTask.new('cruise') do |t|
|
72
|
+
t.spec_files = FileList['spec/**/*.rb']
|
73
|
+
t.rcov = true
|
74
|
+
t.rcov_opts = ['--exclude', 'spec', '--exclude', 'Library', '--exclude', 'rcov.rb']
|
75
|
+
end
|
76
|
+
|
77
|
+
desc "Run all examples"
|
78
|
+
Spec::Rake::SpecTask.new('spec') do |t|
|
79
|
+
t.spec_files = FileList['spec/**/*.rb']
|
80
|
+
t.rcov = false
|
81
|
+
t.spec_opts = ['-cfs']
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
if !defined?(Gem)
|
86
|
+
puts "Package target requires RubyGEMs"
|
87
|
+
else
|
88
|
+
desc "sudo gem uninstall aasm && rake gem && sudo gem install pkg/aasm-3.0.0.gem"
|
89
|
+
task :reinstall do
|
90
|
+
puts `sudo gem uninstall aasm && rake gem && sudo gem install pkg/aasm-3.0.0.gem`
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
task :default => [:spec]
|
data/TODO
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
Before Next Release:
|
2
|
+
|
3
|
+
* Add #aasm_next_state_for_event
|
4
|
+
* Add #aasm_next_states_for_event
|
5
|
+
|
6
|
+
Cool ideas from users:
|
7
|
+
|
8
|
+
* Support multiple state machines on one object (Chris Nelson)
|
9
|
+
* http://justbarebones.blogspot.com/2007/11/actsasstatemachine-enhancements.html (Chetan Patil)
|