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.
Files changed (120) hide show
  1. data/.gitignore +11 -0
  2. data/.travis.yml +16 -0
  3. data/.yardopts +5 -0
  4. data/Appraisals +260 -0
  5. data/CHANGELOG.rdoc +15 -0
  6. data/Gemfile +3 -0
  7. data/README.rdoc +156 -29
  8. data/Rakefile +31 -57
  9. data/gemfiles/active_model-3.0.0.gemfile +7 -0
  10. data/gemfiles/active_model-3.0.0.gemfile.lock +32 -0
  11. data/gemfiles/active_model-3.0.5.gemfile +7 -0
  12. data/gemfiles/active_model-3.0.5.gemfile.lock +32 -0
  13. data/gemfiles/active_record-2.0.0.gemfile +8 -0
  14. data/gemfiles/active_record-2.0.0.gemfile.lock +30 -0
  15. data/gemfiles/active_record-2.0.5.gemfile +8 -0
  16. data/gemfiles/active_record-2.0.5.gemfile.lock +30 -0
  17. data/gemfiles/active_record-2.1.0.gemfile +8 -0
  18. data/gemfiles/active_record-2.1.0.gemfile.lock +30 -0
  19. data/gemfiles/active_record-2.1.2.gemfile +8 -0
  20. data/gemfiles/active_record-2.1.2.gemfile.lock +30 -0
  21. data/gemfiles/active_record-2.2.3.gemfile +8 -0
  22. data/gemfiles/active_record-2.2.3.gemfile.lock +30 -0
  23. data/gemfiles/active_record-2.3.12.gemfile +8 -0
  24. data/gemfiles/active_record-2.3.12.gemfile.lock +30 -0
  25. data/gemfiles/active_record-3.0.0.gemfile +8 -0
  26. data/gemfiles/active_record-3.0.0.gemfile.lock +44 -0
  27. data/gemfiles/active_record-3.0.5.gemfile +8 -0
  28. data/gemfiles/active_record-3.0.5.gemfile.lock +43 -0
  29. data/gemfiles/data_mapper-0.10.2.gemfile +12 -0
  30. data/gemfiles/data_mapper-0.10.2.gemfile.lock +45 -0
  31. data/gemfiles/data_mapper-0.9.11.gemfile +12 -0
  32. data/gemfiles/data_mapper-0.9.11.gemfile.lock +47 -0
  33. data/gemfiles/data_mapper-0.9.4.gemfile +12 -0
  34. data/gemfiles/data_mapper-0.9.4.gemfile.lock +61 -0
  35. data/gemfiles/data_mapper-0.9.7.gemfile +12 -0
  36. data/gemfiles/data_mapper-0.9.7.gemfile.lock +57 -0
  37. data/gemfiles/data_mapper-1.0.0.gemfile +12 -0
  38. data/gemfiles/data_mapper-1.0.0.gemfile.lock +53 -0
  39. data/gemfiles/data_mapper-1.0.1.gemfile +12 -0
  40. data/gemfiles/data_mapper-1.0.1.gemfile.lock +53 -0
  41. data/gemfiles/data_mapper-1.0.2.gemfile +12 -0
  42. data/gemfiles/data_mapper-1.0.2.gemfile.lock +53 -0
  43. data/gemfiles/data_mapper-1.1.0.gemfile +12 -0
  44. data/gemfiles/data_mapper-1.1.0.gemfile.lock +51 -0
  45. data/gemfiles/default.gemfile +7 -0
  46. data/gemfiles/default.gemfile.lock +24 -0
  47. data/gemfiles/mongo_mapper-0.5.5.gemfile +8 -0
  48. data/gemfiles/mongo_mapper-0.5.5.gemfile.lock +33 -0
  49. data/gemfiles/mongo_mapper-0.5.8.gemfile +8 -0
  50. data/gemfiles/mongo_mapper-0.5.8.gemfile.lock +33 -0
  51. data/gemfiles/mongo_mapper-0.6.0.gemfile +8 -0
  52. data/gemfiles/mongo_mapper-0.6.0.gemfile.lock +33 -0
  53. data/gemfiles/mongo_mapper-0.6.10.gemfile +8 -0
  54. data/gemfiles/mongo_mapper-0.6.10.gemfile.lock +33 -0
  55. data/gemfiles/mongo_mapper-0.7.0.gemfile +8 -0
  56. data/gemfiles/mongo_mapper-0.7.0.gemfile.lock +33 -0
  57. data/gemfiles/mongo_mapper-0.7.5.gemfile +8 -0
  58. data/gemfiles/mongo_mapper-0.7.5.gemfile.lock +36 -0
  59. data/gemfiles/mongo_mapper-0.8.0.gemfile +10 -0
  60. data/gemfiles/mongo_mapper-0.8.0.gemfile.lock +40 -0
  61. data/gemfiles/mongo_mapper-0.8.3.gemfile +10 -0
  62. data/gemfiles/mongo_mapper-0.8.3.gemfile.lock +40 -0
  63. data/gemfiles/mongo_mapper-0.8.4.gemfile +8 -0
  64. data/gemfiles/mongo_mapper-0.8.4.gemfile.lock +38 -0
  65. data/gemfiles/mongo_mapper-0.8.6.gemfile +8 -0
  66. data/gemfiles/mongo_mapper-0.8.6.gemfile.lock +38 -0
  67. data/gemfiles/mongo_mapper-0.9.0.gemfile +7 -0
  68. data/gemfiles/mongo_mapper-0.9.0.gemfile.lock +41 -0
  69. data/gemfiles/mongoid-2.0.0.gemfile +7 -0
  70. data/gemfiles/mongoid-2.0.0.gemfile.lock +42 -0
  71. data/gemfiles/mongoid-2.1.4.gemfile +7 -0
  72. data/gemfiles/mongoid-2.1.4.gemfile.lock +40 -0
  73. data/gemfiles/sequel-2.11.0.gemfile +8 -0
  74. data/gemfiles/sequel-2.11.0.gemfile.lock +28 -0
  75. data/gemfiles/sequel-2.12.0.gemfile +8 -0
  76. data/gemfiles/sequel-2.12.0.gemfile.lock +28 -0
  77. data/gemfiles/sequel-2.8.0.gemfile +8 -0
  78. data/gemfiles/sequel-2.8.0.gemfile.lock +28 -0
  79. data/gemfiles/sequel-3.0.0.gemfile +8 -0
  80. data/gemfiles/sequel-3.0.0.gemfile.lock +28 -0
  81. data/gemfiles/sequel-3.13.0.gemfile +8 -0
  82. data/gemfiles/sequel-3.13.0.gemfile.lock +28 -0
  83. data/gemfiles/sequel-3.14.0.gemfile +8 -0
  84. data/gemfiles/sequel-3.14.0.gemfile.lock +28 -0
  85. data/gemfiles/sequel-3.23.0.gemfile +8 -0
  86. data/gemfiles/sequel-3.23.0.gemfile.lock +28 -0
  87. data/gemfiles/sequel-3.24.0.gemfile +8 -0
  88. data/gemfiles/sequel-3.24.0.gemfile.lock +28 -0
  89. data/lib/state_machine/event.rb +13 -90
  90. data/lib/state_machine/helper_module.rb +17 -0
  91. data/lib/state_machine/integrations/active_model.rb +35 -0
  92. data/lib/state_machine/integrations/active_record.rb +41 -2
  93. data/lib/state_machine/integrations/data_mapper.rb +17 -2
  94. data/lib/state_machine/integrations/mongo_mapper.rb +34 -7
  95. data/lib/state_machine/integrations/mongoid.rb +34 -26
  96. data/lib/state_machine/integrations/mongoid/versions.rb +29 -3
  97. data/lib/state_machine/integrations/sequel.rb +22 -72
  98. data/lib/state_machine/integrations/sequel/versions.rb +87 -6
  99. data/lib/state_machine/machine.rb +279 -19
  100. data/lib/state_machine/state.rb +2 -2
  101. data/lib/state_machine/state_context.rb +133 -0
  102. data/lib/state_machine/version.rb +3 -0
  103. data/state_machine.gemspec +22 -0
  104. data/test/test_helper.rb +1 -3
  105. data/test/unit/branch_test.rb +1 -3
  106. data/test/unit/event_collection_test.rb +3 -3
  107. data/test/unit/event_test.rb +1 -3
  108. data/test/unit/helper_module_test.rb +17 -0
  109. data/test/unit/integrations/active_model_test.rb +0 -4
  110. data/test/unit/integrations/active_record_test.rb +50 -9
  111. data/test/unit/integrations/data_mapper_test.rb +267 -253
  112. data/test/unit/integrations/mongo_mapper_test.rb +47 -15
  113. data/test/unit/integrations/mongoid_test.rb +50 -8
  114. data/test/unit/integrations/sequel_test.rb +10 -6
  115. data/test/unit/machine_test.rb +206 -25
  116. data/test/unit/state_context_test.rb +421 -0
  117. data/test/unit/state_test.rb +20 -3
  118. metadata +303 -128
  119. data/lib/state_machine/condition_proxy.rb +0 -94
  120. 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 'rake/rdoctask'
5
- require 'rake/gempackagetask'
7
+ require 'rcov/rcovtask'
6
8
 
7
- spec = Gem::Specification.new do |s|
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 the #{spec.name} plugin."
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 = ENV['INTEGRATION'] ? Dir["test/unit/integrations/#{ENV['INTEGRATION']}_test.rb"] : Dir['test/{functional,unit}/*_test.rb'] + ['test/unit/integrations/base_test.rb']
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
- begin
36
- require 'rcov/rcovtask'
37
- namespace :test do
38
- desc "Test the #{spec.name} plugin with Rcov."
39
- Rcov::RcovTask.new(:rcov) do |t|
40
- t.libs << 'lib'
41
- t.test_files = spec.test_files
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
- desc "Generate documentation for the #{spec.name} plugin."
50
- Rake::RDocTask.new(:rdoc) do |rdoc|
51
- rdoc.rdoc_dir = 'rdoc'
52
- rdoc.title = spec.name
53
- rdoc.template = '../rdoc_template.rb'
54
- rdoc.options << '--line-numbers' << '--inline-source' << '--main=README.rdoc'
55
- rdoc.rdoc_files.include('README.rdoc', 'CHANGELOG.rdoc', 'LICENSE', 'lib/**/*.rb')
56
- end
57
-
58
- desc 'Generate a gemspec file.'
59
- task :gemspec do
60
- File.open("#{spec.name}.gemspec", 'w') do |f|
61
- f.write spec.to_ruby
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,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://www.rubygems.org"
4
+
5
+ gem "activemodel", "3.0.0"
6
+
7
+ gemspec :path=>"../"
@@ -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,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://www.rubygems.org"
4
+
5
+ gem "activemodel", "3.0.5"
6
+
7
+ gemspec :path=>"../"
@@ -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,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://www.rubygems.org"
4
+
5
+ gem "activerecord", "2.0.0"
6
+ gem "sqlite3-ruby", "1.3.1"
7
+
8
+ gemspec :path=>"../"
@@ -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,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://www.rubygems.org"
4
+
5
+ gem "activerecord", "2.0.5"
6
+ gem "sqlite3-ruby", "1.3.1"
7
+
8
+ gemspec :path=>"../"
@@ -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,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://www.rubygems.org"
4
+
5
+ gem "activerecord", "2.1.0"
6
+ gem "sqlite3-ruby", "1.3.1"
7
+
8
+ gemspec :path=>"../"
@@ -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,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://www.rubygems.org"
4
+
5
+ gem "activerecord", "2.1.2"
6
+ gem "sqlite3-ruby", "1.3.1"
7
+
8
+ gemspec :path=>"../"
@@ -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,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://www.rubygems.org"
4
+
5
+ gem "activerecord", "2.2.3"
6
+ gem "sqlite3-ruby", "1.3.1"
7
+
8
+ gemspec :path=>"../"
@@ -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,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://www.rubygems.org"
4
+
5
+ gem "activerecord", "2.3.12"
6
+ gem "sqlite3-ruby", "1.3.1"
7
+
8
+ gemspec :path=>"../"
@@ -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!