aasm 2.1.5 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +4 -0
- data/VERSION +1 -1
- data/aasm.gemspec +94 -0
- data/lib/aasm/aasm.rb +1 -0
- data/lib/aasm/persistence/active_record_persistence.rb +21 -11
- data/spec/functional/conversation_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -2
- data/spec/unit/aasm_spec.rb +2 -2
- data/spec/unit/active_record_persistence_spec.rb +7 -6
- data/spec/unit/before_after_callbacks_spec.rb +1 -1
- data/spec/unit/event_spec.rb +1 -1
- data/spec/unit/state_spec.rb +1 -1
- data/spec/unit/state_transition_spec.rb +1 -1
- metadata +36 -17
data/README.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.0
|
data/aasm.gemspec
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{aasm}
|
8
|
+
s.version = "2.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Scott Barron", "Scott Petersen", "Travis Tilley"]
|
12
|
+
s.date = %q{2010-09-13}
|
13
|
+
s.description = %q{AASM is a continuation of the acts as state machine rails plugin, built for plain Ruby objects.}
|
14
|
+
s.email = %q{scott@elitists.net, ttilley@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
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/test_helper.rb",
|
47
|
+
"test/unit/aasm_test.rb",
|
48
|
+
"test/unit/event_test.rb",
|
49
|
+
"test/unit/state_test.rb",
|
50
|
+
"test/unit/state_transition_test.rb"
|
51
|
+
]
|
52
|
+
s.homepage = %q{http://rubyist.github.com/aasm/}
|
53
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
54
|
+
s.require_paths = ["lib"]
|
55
|
+
s.rubygems_version = %q{1.3.7}
|
56
|
+
s.summary = %q{State machine mixin for Ruby objects}
|
57
|
+
s.test_files = [
|
58
|
+
"spec/functional/conversation.rb",
|
59
|
+
"spec/functional/conversation_spec.rb",
|
60
|
+
"spec/spec_helper.rb",
|
61
|
+
"spec/unit/aasm_spec.rb",
|
62
|
+
"spec/unit/active_record_persistence_spec.rb",
|
63
|
+
"spec/unit/before_after_callbacks_spec.rb",
|
64
|
+
"spec/unit/event_spec.rb",
|
65
|
+
"spec/unit/state_spec.rb",
|
66
|
+
"spec/unit/state_transition_spec.rb",
|
67
|
+
"test/functional/auth_machine_test.rb",
|
68
|
+
"test/test_helper.rb",
|
69
|
+
"test/unit/aasm_test.rb",
|
70
|
+
"test/unit/event_test.rb",
|
71
|
+
"test/unit/state_test.rb",
|
72
|
+
"test/unit/state_transition_test.rb"
|
73
|
+
]
|
74
|
+
|
75
|
+
if s.respond_to? :specification_version then
|
76
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
77
|
+
s.specification_version = 3
|
78
|
+
|
79
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
80
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
81
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
82
|
+
s.add_development_dependency(%q<sdoc>, [">= 0"])
|
83
|
+
else
|
84
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
85
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
86
|
+
s.add_dependency(%q<sdoc>, [">= 0"])
|
87
|
+
end
|
88
|
+
else
|
89
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
90
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
91
|
+
s.add_dependency(%q<sdoc>, [">= 0"])
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
data/lib/aasm/aasm.rb
CHANGED
@@ -13,7 +13,7 @@ module AASM
|
|
13
13
|
#
|
14
14
|
# Adds
|
15
15
|
#
|
16
|
-
#
|
16
|
+
# before_validation :aasm_ensure_initial_state, :on => :create
|
17
17
|
#
|
18
18
|
# As a result, it doesn't matter when you define your methods - the following 2 are equivalent
|
19
19
|
#
|
@@ -38,24 +38,28 @@ module AASM
|
|
38
38
|
base.send(:include, AASM::Persistence::ActiveRecordPersistence::WriteState) unless base.method_defined?(:aasm_write_state)
|
39
39
|
base.send(:include, AASM::Persistence::ActiveRecordPersistence::WriteStateWithoutPersistence) unless base.method_defined?(:aasm_write_state_without_persistence)
|
40
40
|
|
41
|
-
if base.respond_to?(:named_scope)
|
41
|
+
if base.respond_to?(:named_scope) || base.respond_to?(:scope)
|
42
42
|
base.extend(AASM::Persistence::ActiveRecordPersistence::NamedScopeMethods)
|
43
43
|
|
44
44
|
base.class_eval do
|
45
45
|
class << self
|
46
|
-
unless method_defined?(:
|
47
|
-
alias_method :
|
48
|
-
alias_method :aasm_state, :
|
46
|
+
unless method_defined?(:aasm_state_without_scope)
|
47
|
+
alias_method :aasm_state_without_scope, :aasm_state
|
48
|
+
alias_method :aasm_state, :aasm_state_with_scope
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
53
|
-
|
54
|
-
|
53
|
+
|
54
|
+
if ActiveRecord::VERSION::MAJOR >= 3
|
55
|
+
base.before_validation(:aasm_ensure_initial_state, :on => :create)
|
56
|
+
else
|
57
|
+
base.before_validation_on_create(:aasm_ensure_initial_state)
|
58
|
+
end
|
55
59
|
end
|
56
60
|
|
57
61
|
module ClassMethods
|
58
|
-
# Maps to the aasm_column in the database.
|
62
|
+
# Maps to the aasm_column in the database. Defaults to "aasm_state". You can write:
|
59
63
|
#
|
60
64
|
# create_table :foos do |t|
|
61
65
|
# t.string :name
|
@@ -237,9 +241,15 @@ module AASM
|
|
237
241
|
end
|
238
242
|
|
239
243
|
module NamedScopeMethods
|
240
|
-
def
|
241
|
-
|
242
|
-
|
244
|
+
def aasm_state_with_scope name, options = {}
|
245
|
+
aasm_state_without_scope name, options
|
246
|
+
|
247
|
+
unless self.respond_to?(name)
|
248
|
+
scope_options = {:conditions => { "#{table_name}.#{self.aasm_column}" => name.to_s}}
|
249
|
+
scope_method = ActiveRecord::VERSION::MAJOR >= 3 ? :scope : :named_scope
|
250
|
+
self.send(scope_method, name, scope_options)
|
251
|
+
end
|
252
|
+
|
243
253
|
end
|
244
254
|
end
|
245
255
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__),
|
2
|
-
require File.join(File.dirname(__FILE__), 'conversation')
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'conversation'))
|
3
3
|
|
4
4
|
describe Conversation, 'description' do
|
5
5
|
it '.aasm_states should contain all of the states' do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
1
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
|
2
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
|
3
3
|
|
4
4
|
require 'aasm'
|
5
5
|
|
data/spec/unit/aasm_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
2
2
|
|
3
3
|
class Foo
|
4
4
|
include AASM
|
@@ -236,7 +236,7 @@ describe AASM, '- event firing without persistence' do
|
|
236
236
|
def foo.aasm_write_state
|
237
237
|
end
|
238
238
|
|
239
|
-
foo.should_receive(:aasm_write_state_without_persistence)
|
239
|
+
foo.should_receive(:aasm_write_state_without_persistence).twice
|
240
240
|
|
241
241
|
foo.close
|
242
242
|
end
|
@@ -1,8 +1,9 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'aasm')
|
2
|
-
|
3
1
|
begin
|
4
2
|
require 'rubygems'
|
5
3
|
require 'active_record'
|
4
|
+
require 'logger'
|
5
|
+
|
6
|
+
ActiveRecord::Base.logger = Logger.new(STDERR)
|
6
7
|
|
7
8
|
# A dummy class for mocking the activerecord connection class
|
8
9
|
class Connection
|
@@ -214,16 +215,16 @@ begin
|
|
214
215
|
end
|
215
216
|
|
216
217
|
context "Does not already respond_to? the scope name" do
|
217
|
-
it "should add a
|
218
|
-
NamedScopeExample.should_receive(:named_scope)
|
218
|
+
it "should add a scope" do
|
219
219
|
NamedScopeExample.aasm_state :unknown_scope
|
220
|
+
NamedScopeExample.scopes.keys.should include(:unknown_scope)
|
220
221
|
end
|
221
222
|
end
|
222
223
|
|
223
224
|
context "Already respond_to? the scope name" do
|
224
|
-
it "should not add a
|
225
|
-
NamedScopeExample.should_not_receive(:named_scope)
|
225
|
+
it "should not add a scope" do
|
226
226
|
NamedScopeExample.aasm_state :new
|
227
|
+
NamedScopeExample.scopes.keys.should_not include(:new)
|
227
228
|
end
|
228
229
|
end
|
229
230
|
end
|
data/spec/unit/event_spec.rb
CHANGED
data/spec/unit/state_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aasm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 2
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 2.2.0
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Scott Barron
|
@@ -11,39 +16,48 @@ autorequire:
|
|
11
16
|
bindir: bin
|
12
17
|
cert_chain: []
|
13
18
|
|
14
|
-
date: 2010-
|
19
|
+
date: 2010-09-13 00:00:00 -04:00
|
15
20
|
default_executable:
|
16
21
|
dependencies:
|
17
22
|
- !ruby/object:Gem::Dependency
|
18
23
|
name: rspec
|
19
|
-
|
20
|
-
|
21
|
-
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
22
27
|
requirements:
|
23
28
|
- - ">="
|
24
29
|
- !ruby/object:Gem::Version
|
30
|
+
segments:
|
31
|
+
- 0
|
25
32
|
version: "0"
|
26
|
-
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
27
35
|
- !ruby/object:Gem::Dependency
|
28
36
|
name: shoulda
|
29
|
-
|
30
|
-
|
31
|
-
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
32
40
|
requirements:
|
33
41
|
- - ">="
|
34
42
|
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 0
|
35
45
|
version: "0"
|
36
|
-
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id002
|
37
48
|
- !ruby/object:Gem::Dependency
|
38
49
|
name: sdoc
|
39
|
-
|
40
|
-
|
41
|
-
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
42
53
|
requirements:
|
43
54
|
- - ">="
|
44
55
|
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 0
|
45
58
|
version: "0"
|
46
|
-
|
59
|
+
type: :development
|
60
|
+
version_requirements: *id003
|
47
61
|
description: AASM is a continuation of the acts as state machine rails plugin, built for plain Ruby objects.
|
48
62
|
email: scott@elitists.net, ttilley@gmail.com
|
49
63
|
executables: []
|
@@ -60,6 +74,7 @@ files:
|
|
60
74
|
- README.rdoc
|
61
75
|
- Rakefile
|
62
76
|
- VERSION
|
77
|
+
- aasm.gemspec
|
63
78
|
- lib/aasm.rb
|
64
79
|
- lib/aasm/aasm.rb
|
65
80
|
- lib/aasm/event.rb
|
@@ -94,21 +109,25 @@ rdoc_options:
|
|
94
109
|
require_paths:
|
95
110
|
- lib
|
96
111
|
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
97
113
|
requirements:
|
98
114
|
- - ">="
|
99
115
|
- !ruby/object:Gem::Version
|
116
|
+
segments:
|
117
|
+
- 0
|
100
118
|
version: "0"
|
101
|
-
version:
|
102
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
103
121
|
requirements:
|
104
122
|
- - ">="
|
105
123
|
- !ruby/object:Gem::Version
|
124
|
+
segments:
|
125
|
+
- 0
|
106
126
|
version: "0"
|
107
|
-
version:
|
108
127
|
requirements: []
|
109
128
|
|
110
129
|
rubyforge_project:
|
111
|
-
rubygems_version: 1.3.
|
130
|
+
rubygems_version: 1.3.7
|
112
131
|
signing_key:
|
113
132
|
specification_version: 3
|
114
133
|
summary: State machine mixin for Ruby objects
|