state_machine 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +11 -0
- data/.travis.yml +16 -0
- data/.yardopts +5 -0
- data/Appraisals +260 -0
- data/CHANGELOG.rdoc +15 -0
- data/Gemfile +3 -0
- data/README.rdoc +156 -29
- data/Rakefile +31 -57
- data/gemfiles/active_model-3.0.0.gemfile +7 -0
- data/gemfiles/active_model-3.0.0.gemfile.lock +32 -0
- data/gemfiles/active_model-3.0.5.gemfile +7 -0
- data/gemfiles/active_model-3.0.5.gemfile.lock +32 -0
- data/gemfiles/active_record-2.0.0.gemfile +8 -0
- data/gemfiles/active_record-2.0.0.gemfile.lock +30 -0
- data/gemfiles/active_record-2.0.5.gemfile +8 -0
- data/gemfiles/active_record-2.0.5.gemfile.lock +30 -0
- data/gemfiles/active_record-2.1.0.gemfile +8 -0
- data/gemfiles/active_record-2.1.0.gemfile.lock +30 -0
- data/gemfiles/active_record-2.1.2.gemfile +8 -0
- data/gemfiles/active_record-2.1.2.gemfile.lock +30 -0
- data/gemfiles/active_record-2.2.3.gemfile +8 -0
- data/gemfiles/active_record-2.2.3.gemfile.lock +30 -0
- data/gemfiles/active_record-2.3.12.gemfile +8 -0
- data/gemfiles/active_record-2.3.12.gemfile.lock +30 -0
- data/gemfiles/active_record-3.0.0.gemfile +8 -0
- data/gemfiles/active_record-3.0.0.gemfile.lock +44 -0
- data/gemfiles/active_record-3.0.5.gemfile +8 -0
- data/gemfiles/active_record-3.0.5.gemfile.lock +43 -0
- data/gemfiles/data_mapper-0.10.2.gemfile +12 -0
- data/gemfiles/data_mapper-0.10.2.gemfile.lock +45 -0
- data/gemfiles/data_mapper-0.9.11.gemfile +12 -0
- data/gemfiles/data_mapper-0.9.11.gemfile.lock +47 -0
- data/gemfiles/data_mapper-0.9.4.gemfile +12 -0
- data/gemfiles/data_mapper-0.9.4.gemfile.lock +61 -0
- data/gemfiles/data_mapper-0.9.7.gemfile +12 -0
- data/gemfiles/data_mapper-0.9.7.gemfile.lock +57 -0
- data/gemfiles/data_mapper-1.0.0.gemfile +12 -0
- data/gemfiles/data_mapper-1.0.0.gemfile.lock +53 -0
- data/gemfiles/data_mapper-1.0.1.gemfile +12 -0
- data/gemfiles/data_mapper-1.0.1.gemfile.lock +53 -0
- data/gemfiles/data_mapper-1.0.2.gemfile +12 -0
- data/gemfiles/data_mapper-1.0.2.gemfile.lock +53 -0
- data/gemfiles/data_mapper-1.1.0.gemfile +12 -0
- data/gemfiles/data_mapper-1.1.0.gemfile.lock +51 -0
- data/gemfiles/default.gemfile +7 -0
- data/gemfiles/default.gemfile.lock +24 -0
- data/gemfiles/mongo_mapper-0.5.5.gemfile +8 -0
- data/gemfiles/mongo_mapper-0.5.5.gemfile.lock +33 -0
- data/gemfiles/mongo_mapper-0.5.8.gemfile +8 -0
- data/gemfiles/mongo_mapper-0.5.8.gemfile.lock +33 -0
- data/gemfiles/mongo_mapper-0.6.0.gemfile +8 -0
- data/gemfiles/mongo_mapper-0.6.0.gemfile.lock +33 -0
- data/gemfiles/mongo_mapper-0.6.10.gemfile +8 -0
- data/gemfiles/mongo_mapper-0.6.10.gemfile.lock +33 -0
- data/gemfiles/mongo_mapper-0.7.0.gemfile +8 -0
- data/gemfiles/mongo_mapper-0.7.0.gemfile.lock +33 -0
- data/gemfiles/mongo_mapper-0.7.5.gemfile +8 -0
- data/gemfiles/mongo_mapper-0.7.5.gemfile.lock +36 -0
- data/gemfiles/mongo_mapper-0.8.0.gemfile +10 -0
- data/gemfiles/mongo_mapper-0.8.0.gemfile.lock +40 -0
- data/gemfiles/mongo_mapper-0.8.3.gemfile +10 -0
- data/gemfiles/mongo_mapper-0.8.3.gemfile.lock +40 -0
- data/gemfiles/mongo_mapper-0.8.4.gemfile +8 -0
- data/gemfiles/mongo_mapper-0.8.4.gemfile.lock +38 -0
- data/gemfiles/mongo_mapper-0.8.6.gemfile +8 -0
- data/gemfiles/mongo_mapper-0.8.6.gemfile.lock +38 -0
- data/gemfiles/mongo_mapper-0.9.0.gemfile +7 -0
- data/gemfiles/mongo_mapper-0.9.0.gemfile.lock +41 -0
- data/gemfiles/mongoid-2.0.0.gemfile +7 -0
- data/gemfiles/mongoid-2.0.0.gemfile.lock +42 -0
- data/gemfiles/mongoid-2.1.4.gemfile +7 -0
- data/gemfiles/mongoid-2.1.4.gemfile.lock +40 -0
- data/gemfiles/sequel-2.11.0.gemfile +8 -0
- data/gemfiles/sequel-2.11.0.gemfile.lock +28 -0
- data/gemfiles/sequel-2.12.0.gemfile +8 -0
- data/gemfiles/sequel-2.12.0.gemfile.lock +28 -0
- data/gemfiles/sequel-2.8.0.gemfile +8 -0
- data/gemfiles/sequel-2.8.0.gemfile.lock +28 -0
- data/gemfiles/sequel-3.0.0.gemfile +8 -0
- data/gemfiles/sequel-3.0.0.gemfile.lock +28 -0
- data/gemfiles/sequel-3.13.0.gemfile +8 -0
- data/gemfiles/sequel-3.13.0.gemfile.lock +28 -0
- data/gemfiles/sequel-3.14.0.gemfile +8 -0
- data/gemfiles/sequel-3.14.0.gemfile.lock +28 -0
- data/gemfiles/sequel-3.23.0.gemfile +8 -0
- data/gemfiles/sequel-3.23.0.gemfile.lock +28 -0
- data/gemfiles/sequel-3.24.0.gemfile +8 -0
- data/gemfiles/sequel-3.24.0.gemfile.lock +28 -0
- data/lib/state_machine/event.rb +13 -90
- data/lib/state_machine/helper_module.rb +17 -0
- data/lib/state_machine/integrations/active_model.rb +35 -0
- data/lib/state_machine/integrations/active_record.rb +41 -2
- data/lib/state_machine/integrations/data_mapper.rb +17 -2
- data/lib/state_machine/integrations/mongo_mapper.rb +34 -7
- data/lib/state_machine/integrations/mongoid.rb +34 -26
- data/lib/state_machine/integrations/mongoid/versions.rb +29 -3
- data/lib/state_machine/integrations/sequel.rb +22 -72
- data/lib/state_machine/integrations/sequel/versions.rb +87 -6
- data/lib/state_machine/machine.rb +279 -19
- data/lib/state_machine/state.rb +2 -2
- data/lib/state_machine/state_context.rb +133 -0
- data/lib/state_machine/version.rb +3 -0
- data/state_machine.gemspec +22 -0
- data/test/test_helper.rb +1 -3
- data/test/unit/branch_test.rb +1 -3
- data/test/unit/event_collection_test.rb +3 -3
- data/test/unit/event_test.rb +1 -3
- data/test/unit/helper_module_test.rb +17 -0
- data/test/unit/integrations/active_model_test.rb +0 -4
- data/test/unit/integrations/active_record_test.rb +50 -9
- data/test/unit/integrations/data_mapper_test.rb +267 -253
- data/test/unit/integrations/mongo_mapper_test.rb +47 -15
- data/test/unit/integrations/mongoid_test.rb +50 -8
- data/test/unit/integrations/sequel_test.rb +10 -6
- data/test/unit/machine_test.rb +206 -25
- data/test/unit/state_context_test.rb +421 -0
- data/test/unit/state_test.rb +20 -3
- metadata +303 -128
- data/lib/state_machine/condition_proxy.rb +0 -94
- data/test/unit/condition_proxy_test.rb +0 -328
data/Rakefile
CHANGED
@@ -1,77 +1,51 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
Bundler.setup
|
4
|
+
|
2
5
|
require 'rake'
|
3
6
|
require 'rake/testtask'
|
4
|
-
require '
|
5
|
-
require 'rake/gempackagetask'
|
7
|
+
require 'rcov/rcovtask'
|
6
8
|
|
7
|
-
|
8
|
-
s.name = 'state_machine'
|
9
|
-
s.version = '1.0.1'
|
10
|
-
s.platform = Gem::Platform::RUBY
|
11
|
-
s.summary = 'Adds support for creating state machines for attributes on any Ruby class'
|
12
|
-
s.description = s.summary
|
13
|
-
|
14
|
-
s.files = FileList['{examples,lib,test}/**/*'] + %w(CHANGELOG.rdoc init.rb LICENSE Rakefile README.rdoc) - FileList['test/*.log']
|
15
|
-
s.require_path = 'lib'
|
16
|
-
s.has_rdoc = true
|
17
|
-
s.test_files = Dir['test/**/*_test.rb']
|
18
|
-
|
19
|
-
s.author = 'Aaron Pfeifer'
|
20
|
-
s.email = 'aaron@pluginaweek.org'
|
21
|
-
s.homepage = 'http://www.pluginaweek.org'
|
22
|
-
s.rubyforge_project = 'pluginaweek'
|
23
|
-
end
|
9
|
+
require 'appraisal'
|
24
10
|
|
25
11
|
desc 'Default: run all tests.'
|
26
12
|
task :default => :test
|
27
13
|
|
28
|
-
desc "Test
|
14
|
+
desc "Test state_machine."
|
29
15
|
Rake::TestTask.new(:test) do |t|
|
16
|
+
integration = %w(active_model active_record data_mapper mongoid mongo_mapper sequel).detect do |name|
|
17
|
+
Bundler.default_gemfile.to_s.include?(name)
|
18
|
+
end
|
19
|
+
|
30
20
|
t.libs << 'lib'
|
31
|
-
t.test_files =
|
21
|
+
t.test_files = integration ? Dir["test/unit/integrations/#{integration}_test.rb"] : Dir['test/{functional,unit}/*_test.rb'] + ['test/unit/integrations/base_test.rb']
|
32
22
|
t.verbose = true
|
33
23
|
end
|
34
24
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
t.rcov_opts << '--exclude="^(?!lib/)"'
|
43
|
-
t.verbose = true
|
44
|
-
end
|
25
|
+
namespace :test do
|
26
|
+
desc "Test state_machine with Rcov."
|
27
|
+
Rcov::RcovTask.new(:rcov) do |t|
|
28
|
+
t.libs << 'lib'
|
29
|
+
t.test_files = Dir['test/**/*_test.rb']
|
30
|
+
t.rcov_opts << '--exclude="^(?!lib/)"'
|
31
|
+
t.verbose = true
|
45
32
|
end
|
46
|
-
rescue LoadError
|
47
33
|
end
|
48
34
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
35
|
+
namespace :appraisal do
|
36
|
+
desc "Run the given task for a particular integration's appraisals"
|
37
|
+
task :integration do
|
38
|
+
integration = ENV['INTEGRATION']
|
39
|
+
|
40
|
+
Appraisal::File.each do |appraisal|
|
41
|
+
if appraisal.name.include?(integration)
|
42
|
+
appraisal.install
|
43
|
+
Appraisal::Command.from_args(appraisal.gemfile_path).run
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
exit
|
62
48
|
end
|
63
49
|
end
|
64
50
|
|
65
|
-
Rake::GemPackageTask.new(spec) do |p|
|
66
|
-
p.gem_spec = spec
|
67
|
-
end
|
68
|
-
|
69
|
-
desc 'Publish the release files to RubyForge.'
|
70
|
-
task :release => :package do
|
71
|
-
require 'rake/gemcutter'
|
72
|
-
|
73
|
-
Rake::Gemcutter::Tasks.new(spec)
|
74
|
-
Rake::Task['gem:push'].invoke
|
75
|
-
end
|
76
|
-
|
77
51
|
load File.dirname(__FILE__) + '/lib/tasks/state_machine.rake'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /home/aaron/Projects/Personal/pluginaweek/state_machine
|
3
|
+
specs:
|
4
|
+
state_machine (1.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://www.rubygems.org/
|
8
|
+
specs:
|
9
|
+
activemodel (3.0.0)
|
10
|
+
activesupport (= 3.0.0)
|
11
|
+
builder (~> 2.1.2)
|
12
|
+
i18n (~> 0.4.1)
|
13
|
+
activesupport (3.0.0)
|
14
|
+
appraisal (0.3.8)
|
15
|
+
bundler
|
16
|
+
rake
|
17
|
+
builder (2.1.2)
|
18
|
+
i18n (0.4.2)
|
19
|
+
rake (0.9.2)
|
20
|
+
rcov (0.9.10)
|
21
|
+
ruby-graphviz (1.0.0)
|
22
|
+
|
23
|
+
PLATFORMS
|
24
|
+
ruby
|
25
|
+
|
26
|
+
DEPENDENCIES
|
27
|
+
activemodel (= 3.0.0)
|
28
|
+
appraisal (~> 0.3.8)
|
29
|
+
rake
|
30
|
+
rcov
|
31
|
+
ruby-graphviz (~> 1.0)
|
32
|
+
state_machine!
|
@@ -0,0 +1,32 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /home/aaron/Projects/Personal/pluginaweek/state_machine
|
3
|
+
specs:
|
4
|
+
state_machine (1.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://www.rubygems.org/
|
8
|
+
specs:
|
9
|
+
activemodel (3.0.5)
|
10
|
+
activesupport (= 3.0.5)
|
11
|
+
builder (~> 2.1.2)
|
12
|
+
i18n (~> 0.4)
|
13
|
+
activesupport (3.0.5)
|
14
|
+
appraisal (0.3.8)
|
15
|
+
bundler
|
16
|
+
rake
|
17
|
+
builder (2.1.2)
|
18
|
+
i18n (0.6.0)
|
19
|
+
rake (0.9.2)
|
20
|
+
rcov (0.9.10)
|
21
|
+
ruby-graphviz (1.0.0)
|
22
|
+
|
23
|
+
PLATFORMS
|
24
|
+
ruby
|
25
|
+
|
26
|
+
DEPENDENCIES
|
27
|
+
activemodel (= 3.0.5)
|
28
|
+
appraisal (~> 0.3.8)
|
29
|
+
rake
|
30
|
+
rcov
|
31
|
+
ruby-graphviz (~> 1.0)
|
32
|
+
state_machine!
|
@@ -0,0 +1,30 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /home/aaron/Projects/Personal/pluginaweek/state_machine
|
3
|
+
specs:
|
4
|
+
state_machine (1.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://www.rubygems.org/
|
8
|
+
specs:
|
9
|
+
activerecord (2.0.0)
|
10
|
+
activesupport (= 2.0.0)
|
11
|
+
activesupport (2.0.0)
|
12
|
+
appraisal (0.3.8)
|
13
|
+
bundler
|
14
|
+
rake
|
15
|
+
rake (0.9.2)
|
16
|
+
rcov (0.9.10)
|
17
|
+
ruby-graphviz (1.0.0)
|
18
|
+
sqlite3-ruby (1.3.1)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
activerecord (= 2.0.0)
|
25
|
+
appraisal (~> 0.3.8)
|
26
|
+
rake
|
27
|
+
rcov
|
28
|
+
ruby-graphviz (~> 1.0)
|
29
|
+
sqlite3-ruby (= 1.3.1)
|
30
|
+
state_machine!
|
@@ -0,0 +1,30 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /home/aaron/Projects/Personal/pluginaweek/state_machine
|
3
|
+
specs:
|
4
|
+
state_machine (1.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://www.rubygems.org/
|
8
|
+
specs:
|
9
|
+
activerecord (2.0.5)
|
10
|
+
activesupport (= 2.0.5)
|
11
|
+
activesupport (2.0.5)
|
12
|
+
appraisal (0.3.8)
|
13
|
+
bundler
|
14
|
+
rake
|
15
|
+
rake (0.9.2)
|
16
|
+
rcov (0.9.10)
|
17
|
+
ruby-graphviz (1.0.0)
|
18
|
+
sqlite3-ruby (1.3.1)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
activerecord (= 2.0.5)
|
25
|
+
appraisal (~> 0.3.8)
|
26
|
+
rake
|
27
|
+
rcov
|
28
|
+
ruby-graphviz (~> 1.0)
|
29
|
+
sqlite3-ruby (= 1.3.1)
|
30
|
+
state_machine!
|
@@ -0,0 +1,30 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /home/aaron/Projects/Personal/pluginaweek/state_machine
|
3
|
+
specs:
|
4
|
+
state_machine (1.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://www.rubygems.org/
|
8
|
+
specs:
|
9
|
+
activerecord (2.1.0)
|
10
|
+
activesupport (= 2.1.0)
|
11
|
+
activesupport (2.1.0)
|
12
|
+
appraisal (0.3.8)
|
13
|
+
bundler
|
14
|
+
rake
|
15
|
+
rake (0.9.2)
|
16
|
+
rcov (0.9.10)
|
17
|
+
ruby-graphviz (1.0.0)
|
18
|
+
sqlite3-ruby (1.3.1)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
activerecord (= 2.1.0)
|
25
|
+
appraisal (~> 0.3.8)
|
26
|
+
rake
|
27
|
+
rcov
|
28
|
+
ruby-graphviz (~> 1.0)
|
29
|
+
sqlite3-ruby (= 1.3.1)
|
30
|
+
state_machine!
|
@@ -0,0 +1,30 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /home/aaron/Projects/Personal/pluginaweek/state_machine
|
3
|
+
specs:
|
4
|
+
state_machine (1.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://www.rubygems.org/
|
8
|
+
specs:
|
9
|
+
activerecord (2.1.2)
|
10
|
+
activesupport (= 2.1.2)
|
11
|
+
activesupport (2.1.2)
|
12
|
+
appraisal (0.3.8)
|
13
|
+
bundler
|
14
|
+
rake
|
15
|
+
rake (0.9.2)
|
16
|
+
rcov (0.9.10)
|
17
|
+
ruby-graphviz (1.0.0)
|
18
|
+
sqlite3-ruby (1.3.1)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
activerecord (= 2.1.2)
|
25
|
+
appraisal (~> 0.3.8)
|
26
|
+
rake
|
27
|
+
rcov
|
28
|
+
ruby-graphviz (~> 1.0)
|
29
|
+
sqlite3-ruby (= 1.3.1)
|
30
|
+
state_machine!
|
@@ -0,0 +1,30 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /home/aaron/Projects/Personal/pluginaweek/state_machine
|
3
|
+
specs:
|
4
|
+
state_machine (1.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://www.rubygems.org/
|
8
|
+
specs:
|
9
|
+
activerecord (2.2.3)
|
10
|
+
activesupport (= 2.2.3)
|
11
|
+
activesupport (2.2.3)
|
12
|
+
appraisal (0.3.8)
|
13
|
+
bundler
|
14
|
+
rake
|
15
|
+
rake (0.9.2)
|
16
|
+
rcov (0.9.10)
|
17
|
+
ruby-graphviz (1.0.0)
|
18
|
+
sqlite3-ruby (1.3.1)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
activerecord (= 2.2.3)
|
25
|
+
appraisal (~> 0.3.8)
|
26
|
+
rake
|
27
|
+
rcov
|
28
|
+
ruby-graphviz (~> 1.0)
|
29
|
+
sqlite3-ruby (= 1.3.1)
|
30
|
+
state_machine!
|
@@ -0,0 +1,30 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /home/aaron/Projects/Personal/pluginaweek/state_machine
|
3
|
+
specs:
|
4
|
+
state_machine (1.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://www.rubygems.org/
|
8
|
+
specs:
|
9
|
+
activerecord (2.3.12)
|
10
|
+
activesupport (= 2.3.12)
|
11
|
+
activesupport (2.3.12)
|
12
|
+
appraisal (0.3.8)
|
13
|
+
bundler
|
14
|
+
rake
|
15
|
+
rake (0.9.2)
|
16
|
+
rcov (0.9.10)
|
17
|
+
ruby-graphviz (1.0.0)
|
18
|
+
sqlite3-ruby (1.3.1)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
activerecord (= 2.3.12)
|
25
|
+
appraisal (~> 0.3.8)
|
26
|
+
rake
|
27
|
+
rcov
|
28
|
+
ruby-graphviz (~> 1.0)
|
29
|
+
sqlite3-ruby (= 1.3.1)
|
30
|
+
state_machine!
|