aasm 2.2.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +16 -0
- data/README.rdoc +2 -0
- data/Rakefile +51 -80
- data/VERSION +1 -1
- data/aasm.gemspec +83 -51
- data/lib/aasm/event.rb +1 -1
- data/lib/aasm/state_machine.rb +6 -7
- data/lib/aasm/state_transition.rb +3 -3
- data/spec/spec_helper.rb +3 -4
- data/spec/unit/active_record_persistence_spec.rb +1 -1
- data/spec/unit/event_spec.rb +14 -0
- data/test/models/process.rb +18 -0
- data/test/test_helper.rb +11 -1
- data/test/unit/state_machine_test.rb +37 -0
- metadata +175 -15
- data/.gitignore +0 -7
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
# Add dependencies to develop your gem here.
|
4
|
+
# Include everything needed to run rake, tests, features, etc.
|
5
|
+
group :development do
|
6
|
+
gem "rspec", ">= 2.0.0"
|
7
|
+
gem "shoulda"
|
8
|
+
gem "sdoc"
|
9
|
+
gem "bundler", ">= 1.0.0"
|
10
|
+
gem "jeweler", ">= 1.5.1"
|
11
|
+
gem "rcov", ">= 0"
|
12
|
+
gem "rr"
|
13
|
+
gem "reek", "~> 1.2.8"
|
14
|
+
gem "roodi", "~> 2.1.0"
|
15
|
+
gem "activerecord"
|
16
|
+
end
|
data/README.rdoc
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
= Alternatives
|
2
2
|
|
3
|
+
This project is essentially abandoned. Thorsten Böttger has volunteered to take over maintenance: https://github.com/alto/aasm
|
4
|
+
|
3
5
|
If you are looking for an alternative to AASM, I would highly suggest transitions: http://github.com/qoobaa/transitions
|
4
6
|
|
5
7
|
= AASM - Ruby state machines
|
data/Rakefile
CHANGED
@@ -1,108 +1,79 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
2
10
|
require 'rake'
|
3
11
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
|
-
end
|
18
|
-
Jeweler::GemcutterTasks.new
|
19
|
-
rescue LoadError
|
20
|
-
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
gem.name = "aasm"
|
15
|
+
gem.summary = %Q{State machine mixin for Ruby objects}
|
16
|
+
gem.description = %Q{AASM is a continuation of the acts as state machine rails plugin, built for plain Ruby objects.}
|
17
|
+
gem.homepage = "http://rubyist.github.com/aasm/"
|
18
|
+
gem.authors = ["Scott Barron", "Scott Petersen", "Travis Tilley"]
|
19
|
+
gem.email = "scott@elitists.net, ttilley@gmail.com"
|
20
|
+
gem.add_development_dependency "rspec"
|
21
|
+
gem.add_development_dependency "shoulda"
|
22
|
+
gem.add_development_dependency 'sdoc'
|
23
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
21
24
|
end
|
25
|
+
Jeweler::RubygemsDotOrgTasks.new
|
22
26
|
|
23
|
-
require '
|
27
|
+
require 'rspec/core/rake_task'
|
24
28
|
require 'rake/testtask'
|
25
|
-
|
26
29
|
Rake::TestTask.new(:test) do |test|
|
27
30
|
test.libs << 'lib' << 'test'
|
28
31
|
test.pattern = 'test/**/*_test.rb'
|
29
32
|
test.verbose = true
|
30
33
|
end
|
31
34
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
test.verbose = true
|
38
|
-
end
|
39
|
-
rescue LoadError
|
40
|
-
task :rcov do
|
41
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
42
|
-
end
|
35
|
+
require 'rcov/rcovtask'
|
36
|
+
Rcov::RcovTask.new(:rcov_shoulda) do |test|
|
37
|
+
test.libs << 'test'
|
38
|
+
test.pattern = 'test/**/*_test.rb'
|
39
|
+
test.verbose = true
|
43
40
|
end
|
44
41
|
|
45
|
-
|
46
|
-
spec.
|
47
|
-
spec.
|
48
|
-
spec.spec_opts = ['-cfs']
|
42
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
43
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
44
|
+
spec.rspec_opts = ['-cfs']
|
49
45
|
end
|
50
46
|
|
51
|
-
|
52
|
-
spec.libs << 'lib' << 'spec'
|
47
|
+
RSpec::Core::RakeTask.new(:rcov_rspec) do |spec|
|
53
48
|
spec.pattern = 'spec/**/*_spec.rb'
|
54
49
|
spec.rcov = true
|
55
50
|
end
|
56
51
|
|
57
|
-
task
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
Reek::RakeTask.new do |t|
|
63
|
-
t.fail_on_error = true
|
64
|
-
t.verbose = false
|
65
|
-
t.source_files = 'lib/**/*.rb'
|
66
|
-
end
|
67
|
-
rescue LoadError
|
68
|
-
task :reek do
|
69
|
-
abort "Reek is not available. In order to run reek, you must: sudo gem install reek"
|
70
|
-
end
|
52
|
+
require 'reek/rake/task'
|
53
|
+
Reek::Rake::Task.new do |t|
|
54
|
+
t.fail_on_error = true
|
55
|
+
t.verbose = false
|
56
|
+
t.source_files = 'lib/**/*.rb'
|
71
57
|
end
|
72
58
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
t.verbose = false
|
78
|
-
end
|
79
|
-
rescue LoadError
|
80
|
-
task :roodi do
|
81
|
-
abort "Roodi is not available. In order to run roodi, you must: sudo gem install roodi"
|
82
|
-
end
|
59
|
+
require 'roodi'
|
60
|
+
require 'roodi_task'
|
61
|
+
RoodiTask.new do |t|
|
62
|
+
t.verbose = false
|
83
63
|
end
|
84
64
|
|
85
65
|
task :default => :test
|
86
66
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
if File.exist?('VERSION')
|
92
|
-
version = File.read('VERSION')
|
93
|
-
else
|
94
|
-
version = ""
|
95
|
-
end
|
96
|
-
|
97
|
-
rdoc.rdoc_dir = 'rdoc'
|
98
|
-
rdoc.title = "aasm #{version}"
|
99
|
-
rdoc.rdoc_files.include('README*')
|
100
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
67
|
+
require 'rake/rdoctask'
|
68
|
+
require 'sdoc'
|
69
|
+
Rake::RDocTask.new do |rdoc|
|
70
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
101
71
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
puts "aasm makes use of the sdoc gem. Install it with: sudo gem install sdoc"
|
107
|
-
end
|
72
|
+
rdoc.rdoc_dir = 'rdoc'
|
73
|
+
rdoc.title = "aasm #{version}"
|
74
|
+
rdoc.rdoc_files.include('README*')
|
75
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
108
76
|
|
77
|
+
rdoc.options << '--fmt' << 'shtml'
|
78
|
+
rdoc.template = 'direct'
|
79
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.2.
|
1
|
+
2.2.1
|
data/aasm.gemspec
CHANGED
@@ -1,91 +1,123 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{aasm}
|
8
|
-
s.version = "2.2.
|
8
|
+
s.version = "2.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Scott Barron", "Scott Petersen", "Travis Tilley"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-08-31}
|
13
13
|
s.description = %q{AASM is a continuation of the acts as state machine rails plugin, built for plain Ruby objects.}
|
14
14
|
s.email = %q{scott@elitists.net, ttilley@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
|
17
|
+
"README.rdoc"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
21
|
+
"Gemfile",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"aasm.gemspec",
|
27
|
+
"lib/aasm.rb",
|
28
|
+
"lib/aasm/aasm.rb",
|
29
|
+
"lib/aasm/event.rb",
|
30
|
+
"lib/aasm/persistence.rb",
|
31
|
+
"lib/aasm/persistence/active_record_persistence.rb",
|
32
|
+
"lib/aasm/state.rb",
|
33
|
+
"lib/aasm/state_machine.rb",
|
34
|
+
"lib/aasm/state_transition.rb",
|
35
|
+
"lib/aasm/supporting_classes.rb",
|
36
|
+
"spec/functional/conversation.rb",
|
37
|
+
"spec/functional/conversation_spec.rb",
|
38
|
+
"spec/spec_helper.rb",
|
39
|
+
"spec/unit/aasm_spec.rb",
|
40
|
+
"spec/unit/active_record_persistence_spec.rb",
|
41
|
+
"spec/unit/before_after_callbacks_spec.rb",
|
42
|
+
"spec/unit/event_spec.rb",
|
43
|
+
"spec/unit/state_spec.rb",
|
44
|
+
"spec/unit/state_transition_spec.rb",
|
45
|
+
"test/functional/auth_machine_test.rb",
|
46
|
+
"test/models/process.rb",
|
47
|
+
"test/test_helper.rb",
|
48
|
+
"test/unit/aasm_test.rb",
|
49
|
+
"test/unit/event_test.rb",
|
50
|
+
"test/unit/state_machine_test.rb",
|
51
|
+
"test/unit/state_test.rb",
|
52
|
+
"test/unit/state_transition_test.rb"
|
51
53
|
]
|
52
54
|
s.homepage = %q{http://rubyist.github.com/aasm/}
|
53
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
54
55
|
s.require_paths = ["lib"]
|
55
|
-
s.rubygems_version = %q{1.
|
56
|
+
s.rubygems_version = %q{1.6.2}
|
56
57
|
s.summary = %q{State machine mixin for Ruby objects}
|
57
58
|
s.test_files = [
|
58
59
|
"spec/functional/conversation.rb",
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
60
|
+
"spec/functional/conversation_spec.rb",
|
61
|
+
"spec/spec_helper.rb",
|
62
|
+
"spec/unit/aasm_spec.rb",
|
63
|
+
"spec/unit/active_record_persistence_spec.rb",
|
64
|
+
"spec/unit/before_after_callbacks_spec.rb",
|
65
|
+
"spec/unit/event_spec.rb",
|
66
|
+
"spec/unit/state_spec.rb",
|
67
|
+
"spec/unit/state_transition_spec.rb",
|
68
|
+
"test/functional/auth_machine_test.rb",
|
69
|
+
"test/models/process.rb",
|
70
|
+
"test/test_helper.rb",
|
71
|
+
"test/unit/aasm_test.rb",
|
72
|
+
"test/unit/event_test.rb",
|
73
|
+
"test/unit/state_machine_test.rb",
|
74
|
+
"test/unit/state_test.rb",
|
75
|
+
"test/unit/state_transition_test.rb"
|
73
76
|
]
|
74
77
|
|
75
78
|
if s.respond_to? :specification_version then
|
76
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
77
79
|
s.specification_version = 3
|
78
80
|
|
79
81
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
82
|
+
s.add_development_dependency(%q<rspec>, [">= 2.0.0"])
|
83
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
84
|
+
s.add_development_dependency(%q<sdoc>, [">= 0"])
|
85
|
+
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
86
|
+
s.add_development_dependency(%q<jeweler>, [">= 1.5.1"])
|
87
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
88
|
+
s.add_development_dependency(%q<rr>, [">= 0"])
|
89
|
+
s.add_development_dependency(%q<reek>, ["~> 1.2.8"])
|
90
|
+
s.add_development_dependency(%q<roodi>, ["~> 2.1.0"])
|
91
|
+
s.add_development_dependency(%q<activerecord>, [">= 0"])
|
80
92
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
81
93
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
82
94
|
s.add_development_dependency(%q<sdoc>, [">= 0"])
|
83
95
|
else
|
96
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0"])
|
97
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
98
|
+
s.add_dependency(%q<sdoc>, [">= 0"])
|
99
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
100
|
+
s.add_dependency(%q<jeweler>, [">= 1.5.1"])
|
101
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
102
|
+
s.add_dependency(%q<rr>, [">= 0"])
|
103
|
+
s.add_dependency(%q<reek>, ["~> 1.2.8"])
|
104
|
+
s.add_dependency(%q<roodi>, ["~> 2.1.0"])
|
105
|
+
s.add_dependency(%q<activerecord>, [">= 0"])
|
84
106
|
s.add_dependency(%q<rspec>, [">= 0"])
|
85
107
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
86
108
|
s.add_dependency(%q<sdoc>, [">= 0"])
|
87
109
|
end
|
88
110
|
else
|
111
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0"])
|
112
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
113
|
+
s.add_dependency(%q<sdoc>, [">= 0"])
|
114
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
115
|
+
s.add_dependency(%q<jeweler>, [">= 1.5.1"])
|
116
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
117
|
+
s.add_dependency(%q<rr>, [">= 0"])
|
118
|
+
s.add_dependency(%q<reek>, ["~> 1.2.8"])
|
119
|
+
s.add_dependency(%q<roodi>, ["~> 2.1.0"])
|
120
|
+
s.add_dependency(%q<activerecord>, [">= 0"])
|
89
121
|
s.add_dependency(%q<rspec>, [">= 0"])
|
90
122
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
91
123
|
s.add_dependency(%q<sdoc>, [">= 0"])
|
data/lib/aasm/event.rb
CHANGED
@@ -14,7 +14,7 @@ class AASM::SupportingClasses::Event
|
|
14
14
|
next_state = nil
|
15
15
|
transitions.each do |transition|
|
16
16
|
next if to_state and !Array(transition.to).include?(to_state)
|
17
|
-
if transition.perform(obj)
|
17
|
+
if transition.perform(obj, *args)
|
18
18
|
next_state = to_state || Array(transition.to).first
|
19
19
|
transition.execute(obj, *args)
|
20
20
|
break
|
data/lib/aasm/state_machine.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
class AASM::StateMachine
|
2
|
-
def self.[](
|
3
|
-
(@machines ||= {})[
|
2
|
+
def self.[](clazz)
|
3
|
+
(@machines ||= {})[clazz.to_s]
|
4
4
|
end
|
5
|
-
|
6
|
-
def self.[]=(
|
7
|
-
|
8
|
-
(@machines ||= {})[args] = val
|
5
|
+
|
6
|
+
def self.[]=(clazz, machine)
|
7
|
+
(@machines ||= {})[clazz.to_s] = machine
|
9
8
|
end
|
10
|
-
|
9
|
+
|
11
10
|
attr_accessor :states, :events, :initial_state, :config
|
12
11
|
attr_reader :name
|
13
12
|
|
@@ -7,12 +7,12 @@ class AASM::SupportingClasses::StateTransition
|
|
7
7
|
@opts = opts
|
8
8
|
end
|
9
9
|
|
10
|
-
def perform(obj)
|
10
|
+
def perform(obj, *args)
|
11
11
|
case @guard
|
12
12
|
when Symbol, String
|
13
|
-
obj.send(@guard)
|
13
|
+
obj.send(@guard, *args)
|
14
14
|
when Proc
|
15
|
-
@guard.call(obj)
|
15
|
+
@guard.call(obj, *args)
|
16
16
|
else
|
17
17
|
true
|
18
18
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
|
2
2
|
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
|
3
|
-
|
4
3
|
require 'aasm'
|
5
4
|
|
6
|
-
require '
|
7
|
-
require '
|
5
|
+
require 'rspec'
|
6
|
+
require 'rspec/autorun'
|
8
7
|
|
9
|
-
|
8
|
+
RSpec.configure do |config|
|
10
9
|
|
11
10
|
end
|
@@ -60,7 +60,7 @@ begin
|
|
60
60
|
attr_accessor :skilled, :aasm_state
|
61
61
|
end
|
62
62
|
|
63
|
-
|
63
|
+
shared_examples_for "aasm model" do
|
64
64
|
it "should include AASM::Persistence::ActiveRecordPersistence" do
|
65
65
|
@klass.included_modules.should be_include(AASM::Persistence::ActiveRecordPersistence)
|
66
66
|
end
|
data/spec/unit/event_spec.rb
CHANGED
@@ -48,6 +48,20 @@ describe AASM::SupportingClasses::Event, 'when firing an event' do
|
|
48
48
|
|
49
49
|
event.fire(obj).should == :closed
|
50
50
|
end
|
51
|
+
|
52
|
+
|
53
|
+
it 'should call the guard with the params passed in' do
|
54
|
+
event = AASM::SupportingClasses::Event.new(:event) do
|
55
|
+
transitions :to => :closed, :from => [:open, :received], :guard => :guard_fn
|
56
|
+
end
|
57
|
+
|
58
|
+
obj = mock('object')
|
59
|
+
obj.stub!(:aasm_current_state).and_return(:open)
|
60
|
+
obj.should_receive(:guard_fn).with('arg1', 'arg2').and_return(true)
|
61
|
+
|
62
|
+
event.fire(obj, nil, 'arg1', 'arg2').should == :closed
|
63
|
+
end
|
64
|
+
|
51
65
|
end
|
52
66
|
|
53
67
|
describe AASM::SupportingClasses::Event, 'when executing the success callback' do
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Models
|
2
|
+
class Process
|
3
|
+
include AASM
|
4
|
+
|
5
|
+
aasm_state :sleeping
|
6
|
+
aasm_state :running
|
7
|
+
aasm_state :suspended
|
8
|
+
|
9
|
+
aasm_event :start do
|
10
|
+
transitions :from => :sleeping, :to => :running
|
11
|
+
end
|
12
|
+
|
13
|
+
aasm_event :stop do
|
14
|
+
transitions :from => :running, :to => :suspended
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
|
1
11
|
require 'ostruct'
|
2
12
|
require 'rubygems'
|
3
13
|
|
@@ -30,4 +40,4 @@ end
|
|
30
40
|
|
31
41
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
32
42
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
33
|
-
require 'aasm'
|
43
|
+
require 'aasm'
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
class StateMachineTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "state machines" do
|
6
|
+
|
7
|
+
should "be created without memory leak" do
|
8
|
+
assert_equal 1, AASM::StateMachine.instance_variable_get("@machines").size # AuthMachine
|
9
|
+
assert_number_of_objects AASM::SupportingClasses::State, 5 # AuthMachine
|
10
|
+
assert_number_of_objects AASM::SupportingClasses::Event, 10 # AuthMachine
|
11
|
+
assert_number_of_objects AASM::SupportingClasses::StateTransition, 18 # AuthMachine
|
12
|
+
|
13
|
+
load File.expand_path(File.dirname(__FILE__) + '/../models/process.rb')
|
14
|
+
assert_equal 2, AASM::StateMachine.instance_variable_get("@machines").size # AuthMachine + Process
|
15
|
+
assert_number_of_objects Models::Process, 0
|
16
|
+
assert_number_of_objects AASM::SupportingClasses::State, 8 # AuthMachine + Process
|
17
|
+
assert_number_of_objects AASM::SupportingClasses::Event, 12 # AuthMachine + Process
|
18
|
+
assert_number_of_objects AASM::SupportingClasses::StateTransition, 20 # AuthMachine + Process
|
19
|
+
|
20
|
+
Models.send(:remove_const, "Process") if Models.const_defined?("Process")
|
21
|
+
load File.expand_path(File.dirname(__FILE__) + '/../models/process.rb')
|
22
|
+
assert_equal 2, AASM::StateMachine.instance_variable_get("@machines").size # AuthMachine + Process
|
23
|
+
assert_number_of_objects AASM::SupportingClasses::State, 8 # AuthMachine + Process
|
24
|
+
assert_number_of_objects AASM::SupportingClasses::Event, 12 # AuthMachine + Process
|
25
|
+
assert_number_of_objects AASM::SupportingClasses::StateTransition, 20 # AuthMachine + Process
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def assert_number_of_objects(clazz, num)
|
33
|
+
count = ObjectSpace.each_object(clazz) {}
|
34
|
+
assert_equal num, count, "#{num} expected, but we had #{count} #{clazz}"
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aasm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 5
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 2
|
7
8
|
- 2
|
8
|
-
-
|
9
|
-
version: 2.2.
|
9
|
+
- 1
|
10
|
+
version: 2.2.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Scott Barron
|
@@ -16,48 +17,201 @@ autorequire:
|
|
16
17
|
bindir: bin
|
17
18
|
cert_chain: []
|
18
19
|
|
19
|
-
date:
|
20
|
+
date: 2011-08-31 00:00:00 +02:00
|
20
21
|
default_executable:
|
21
22
|
dependencies:
|
22
23
|
- !ruby/object:Gem::Dependency
|
23
|
-
name: rspec
|
24
24
|
prerelease: false
|
25
|
+
type: :development
|
25
26
|
requirement: &id001 !ruby/object:Gem::Requirement
|
26
27
|
none: false
|
27
28
|
requirements:
|
28
29
|
- - ">="
|
29
30
|
- !ruby/object:Gem::Version
|
31
|
+
hash: 15
|
30
32
|
segments:
|
33
|
+
- 2
|
31
34
|
- 0
|
32
|
-
|
33
|
-
|
35
|
+
- 0
|
36
|
+
version: 2.0.0
|
37
|
+
name: rspec
|
34
38
|
version_requirements: *id001
|
35
39
|
- !ruby/object:Gem::Dependency
|
36
|
-
name: shoulda
|
37
40
|
prerelease: false
|
41
|
+
type: :development
|
38
42
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
43
|
none: false
|
40
44
|
requirements:
|
41
45
|
- - ">="
|
42
46
|
- !ruby/object:Gem::Version
|
47
|
+
hash: 3
|
43
48
|
segments:
|
44
49
|
- 0
|
45
50
|
version: "0"
|
46
|
-
|
51
|
+
name: shoulda
|
47
52
|
version_requirements: *id002
|
48
53
|
- !ruby/object:Gem::Dependency
|
49
|
-
name: sdoc
|
50
54
|
prerelease: false
|
55
|
+
type: :development
|
51
56
|
requirement: &id003 !ruby/object:Gem::Requirement
|
52
57
|
none: false
|
53
58
|
requirements:
|
54
59
|
- - ">="
|
55
60
|
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
56
62
|
segments:
|
57
63
|
- 0
|
58
64
|
version: "0"
|
59
|
-
|
65
|
+
name: sdoc
|
60
66
|
version_requirements: *id003
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
prerelease: false
|
69
|
+
type: :development
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 23
|
76
|
+
segments:
|
77
|
+
- 1
|
78
|
+
- 0
|
79
|
+
- 0
|
80
|
+
version: 1.0.0
|
81
|
+
name: bundler
|
82
|
+
version_requirements: *id004
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
prerelease: false
|
85
|
+
type: :development
|
86
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
hash: 1
|
92
|
+
segments:
|
93
|
+
- 1
|
94
|
+
- 5
|
95
|
+
- 1
|
96
|
+
version: 1.5.1
|
97
|
+
name: jeweler
|
98
|
+
version_requirements: *id005
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
prerelease: false
|
101
|
+
type: :development
|
102
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
hash: 3
|
108
|
+
segments:
|
109
|
+
- 0
|
110
|
+
version: "0"
|
111
|
+
name: rcov
|
112
|
+
version_requirements: *id006
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
prerelease: false
|
115
|
+
type: :development
|
116
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
117
|
+
none: false
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
hash: 3
|
122
|
+
segments:
|
123
|
+
- 0
|
124
|
+
version: "0"
|
125
|
+
name: rr
|
126
|
+
version_requirements: *id007
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
prerelease: false
|
129
|
+
type: :development
|
130
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
132
|
+
requirements:
|
133
|
+
- - ~>
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
hash: 15
|
136
|
+
segments:
|
137
|
+
- 1
|
138
|
+
- 2
|
139
|
+
- 8
|
140
|
+
version: 1.2.8
|
141
|
+
name: reek
|
142
|
+
version_requirements: *id008
|
143
|
+
- !ruby/object:Gem::Dependency
|
144
|
+
prerelease: false
|
145
|
+
type: :development
|
146
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
147
|
+
none: false
|
148
|
+
requirements:
|
149
|
+
- - ~>
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
hash: 11
|
152
|
+
segments:
|
153
|
+
- 2
|
154
|
+
- 1
|
155
|
+
- 0
|
156
|
+
version: 2.1.0
|
157
|
+
name: roodi
|
158
|
+
version_requirements: *id009
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
prerelease: false
|
161
|
+
type: :development
|
162
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
163
|
+
none: false
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
hash: 3
|
168
|
+
segments:
|
169
|
+
- 0
|
170
|
+
version: "0"
|
171
|
+
name: activerecord
|
172
|
+
version_requirements: *id010
|
173
|
+
- !ruby/object:Gem::Dependency
|
174
|
+
prerelease: false
|
175
|
+
type: :development
|
176
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ">="
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
hash: 3
|
182
|
+
segments:
|
183
|
+
- 0
|
184
|
+
version: "0"
|
185
|
+
name: rspec
|
186
|
+
version_requirements: *id011
|
187
|
+
- !ruby/object:Gem::Dependency
|
188
|
+
prerelease: false
|
189
|
+
type: :development
|
190
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
191
|
+
none: false
|
192
|
+
requirements:
|
193
|
+
- - ">="
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
hash: 3
|
196
|
+
segments:
|
197
|
+
- 0
|
198
|
+
version: "0"
|
199
|
+
name: shoulda
|
200
|
+
version_requirements: *id012
|
201
|
+
- !ruby/object:Gem::Dependency
|
202
|
+
prerelease: false
|
203
|
+
type: :development
|
204
|
+
requirement: &id013 !ruby/object:Gem::Requirement
|
205
|
+
none: false
|
206
|
+
requirements:
|
207
|
+
- - ">="
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
hash: 3
|
210
|
+
segments:
|
211
|
+
- 0
|
212
|
+
version: "0"
|
213
|
+
name: sdoc
|
214
|
+
version_requirements: *id013
|
61
215
|
description: AASM is a continuation of the acts as state machine rails plugin, built for plain Ruby objects.
|
62
216
|
email: scott@elitists.net, ttilley@gmail.com
|
63
217
|
executables: []
|
@@ -69,7 +223,7 @@ extra_rdoc_files:
|
|
69
223
|
- README.rdoc
|
70
224
|
files:
|
71
225
|
- .document
|
72
|
-
-
|
226
|
+
- Gemfile
|
73
227
|
- LICENSE
|
74
228
|
- README.rdoc
|
75
229
|
- Rakefile
|
@@ -94,9 +248,11 @@ files:
|
|
94
248
|
- spec/unit/state_spec.rb
|
95
249
|
- spec/unit/state_transition_spec.rb
|
96
250
|
- test/functional/auth_machine_test.rb
|
251
|
+
- test/models/process.rb
|
97
252
|
- test/test_helper.rb
|
98
253
|
- test/unit/aasm_test.rb
|
99
254
|
- test/unit/event_test.rb
|
255
|
+
- test/unit/state_machine_test.rb
|
100
256
|
- test/unit/state_test.rb
|
101
257
|
- test/unit/state_transition_test.rb
|
102
258
|
has_rdoc: true
|
@@ -104,8 +260,8 @@ homepage: http://rubyist.github.com/aasm/
|
|
104
260
|
licenses: []
|
105
261
|
|
106
262
|
post_install_message:
|
107
|
-
rdoc_options:
|
108
|
-
|
263
|
+
rdoc_options: []
|
264
|
+
|
109
265
|
require_paths:
|
110
266
|
- lib
|
111
267
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -113,6 +269,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
269
|
requirements:
|
114
270
|
- - ">="
|
115
271
|
- !ruby/object:Gem::Version
|
272
|
+
hash: 3
|
116
273
|
segments:
|
117
274
|
- 0
|
118
275
|
version: "0"
|
@@ -121,13 +278,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
278
|
requirements:
|
122
279
|
- - ">="
|
123
280
|
- !ruby/object:Gem::Version
|
281
|
+
hash: 3
|
124
282
|
segments:
|
125
283
|
- 0
|
126
284
|
version: "0"
|
127
285
|
requirements: []
|
128
286
|
|
129
287
|
rubyforge_project:
|
130
|
-
rubygems_version: 1.
|
288
|
+
rubygems_version: 1.6.2
|
131
289
|
signing_key:
|
132
290
|
specification_version: 3
|
133
291
|
summary: State machine mixin for Ruby objects
|
@@ -142,8 +300,10 @@ test_files:
|
|
142
300
|
- spec/unit/state_spec.rb
|
143
301
|
- spec/unit/state_transition_spec.rb
|
144
302
|
- test/functional/auth_machine_test.rb
|
303
|
+
- test/models/process.rb
|
145
304
|
- test/test_helper.rb
|
146
305
|
- test/unit/aasm_test.rb
|
147
306
|
- test/unit/event_test.rb
|
307
|
+
- test/unit/state_machine_test.rb
|
148
308
|
- test/unit/state_test.rb
|
149
309
|
- test/unit/state_transition_test.rb
|