transitions 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = state_machine
1
+ = transitions
2
2
 
3
3
  The gem is based on Rick Olson's code of ActiveModel::StateMachine,
4
4
  axed from ActiveModel in {this
@@ -6,11 +6,9 @@ commit}[http://github.com/rails/rails/commit/db49c706b62e7ea2ab93f05399dbfddf508
6
6
 
7
7
  == Installation
8
8
 
9
- Currently there's no gem released on gemcutter (we need a different
10
- name). However it's fully usable in bundler, you can just paste the
11
- following line into the Gemfile:
9
+ Just paste the following line into the Gemfile:
12
10
 
13
- gem "state_machine", :git => "git://github.com/qoobaa/state_machine.git"
11
+ gem "transitions"
14
12
 
15
13
  == Note on Patches/Pull Requests
16
14
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -21,11 +21,11 @@
21
21
  # SOFTWARE.
22
22
 
23
23
  module ActiveRecord
24
- module StateMachine
24
+ module Transitions
25
25
  extend ActiveSupport::Concern
26
26
 
27
27
  included do
28
- include ::StateMachine
28
+ include ::Transitions
29
29
  before_validation :set_initial_state
30
30
  validates_presence_of :state
31
31
  end
@@ -20,7 +20,7 @@
20
20
  # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  # SOFTWARE.
22
22
 
23
- module StateMachine
23
+ module Transitions
24
24
  class Event
25
25
  attr_reader :name, :success
26
26
 
@@ -20,7 +20,7 @@
20
20
  # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  # SOFTWARE.
22
22
 
23
- module StateMachine
23
+ module Transitions
24
24
  class Machine
25
25
  attr_writer :initial_state
26
26
  attr_accessor :states, :events, :state_index
@@ -20,7 +20,7 @@
20
20
  # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  # SOFTWARE.
22
22
 
23
- module StateMachine
23
+ module Transitions
24
24
  class State
25
25
  attr_reader :name, :options
26
26
 
@@ -20,7 +20,7 @@
20
20
  # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  # SOFTWARE.
22
22
 
23
- module StateMachine
23
+ module Transitions
24
24
  class StateTransition
25
25
  attr_reader :from, :to, :options
26
26
 
@@ -20,12 +20,12 @@
20
20
  # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  # SOFTWARE.
22
22
 
23
- require "state_machine/event"
24
- require "state_machine/machine"
25
- require "state_machine/state"
26
- require "state_machine/state_transition"
23
+ require "transitions/event"
24
+ require "transitions/machine"
25
+ require "transitions/state"
26
+ require "transitions/state_transition"
27
27
 
28
- module StateMachine
28
+ module Transitions
29
29
  class InvalidTransition < Exception
30
30
 
31
31
  end
data/test/helper.rb CHANGED
@@ -6,8 +6,8 @@ require "mocha"
6
6
 
7
7
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
8
8
  $LOAD_PATH.unshift(File.dirname(__FILE__))
9
- require "state_machine"
10
- require "active_record/state_machine"
9
+ require "transitions"
10
+ require "active_record/transitions"
11
11
 
12
12
  class Test::Unit::TestCase
13
13
 
@@ -7,7 +7,7 @@ class CreateTrafficLights < ActiveRecord::Migration
7
7
  end
8
8
 
9
9
  class TrafficLight < ActiveRecord::Base
10
- include ActiveRecord::StateMachine
10
+ include ActiveRecord::Transitions
11
11
 
12
12
  state_machine do
13
13
  state :off
@@ -73,7 +73,7 @@ class TestActiveRecord < Test::Unit::TestCase
73
73
  end
74
74
 
75
75
  test "transition to an invalid state" do
76
- assert_raise(StateMachine::InvalidTransition) { @light.yellow_on }
76
+ assert_raise(Transitions::InvalidTransition) { @light.yellow_on }
77
77
  assert_equal :off, @light.current_state
78
78
  end
79
79
  end
data/test/test_event.rb CHANGED
@@ -7,7 +7,7 @@ class TestEvent < Test::Unit::TestCase
7
7
  end
8
8
 
9
9
  def new_event
10
- @event = StateMachine::Event.new(nil, @state_name, {:success => @success}) do
10
+ @event = Transitions::Event.new(nil, @state_name, {:success => @success}) do
11
11
  transitions :to => :closed, :from => [:open, :received]
12
12
  end
13
13
  end
@@ -21,8 +21,8 @@ class TestEvent < Test::Unit::TestCase
21
21
  end
22
22
 
23
23
  test "should create StateTransitions" do
24
- StateMachine::StateTransition.expects(:new).with(:to => :closed, :from => :open)
25
- StateMachine::StateTransition.expects(:new).with(:to => :closed, :from => :received)
24
+ Transitions::StateTransition.expects(:new).with(:to => :closed, :from => :open)
25
+ Transitions::StateTransition.expects(:new).with(:to => :closed, :from => :received)
26
26
  new_event
27
27
  end
28
28
  end
@@ -1,7 +1,7 @@
1
1
  require "helper"
2
2
 
3
3
  class ArgumentsTestSubject
4
- include StateMachine
4
+ include Transitions
5
5
  attr_accessor :date
6
6
 
7
7
  state_machine do
@@ -1,16 +1,16 @@
1
1
  require "helper"
2
2
 
3
3
  class TestEventBeingFired < Test::Unit::TestCase
4
- test "should raise an StateMachine::InvalidTransition error if the transitions are empty" do
5
- event = StateMachine::Event.new(nil, :event)
4
+ test "should raise an Transitions::InvalidTransition error if the transitions are empty" do
5
+ event = Transitions::Event.new(nil, :event)
6
6
 
7
- assert_raise StateMachine::InvalidTransition do
7
+ assert_raise Transitions::InvalidTransition do
8
8
  event.fire(nil)
9
9
  end
10
10
  end
11
11
 
12
12
  test "should return the state of the first matching transition it finds" do
13
- event = StateMachine::Event.new(nil, :event) do
13
+ event = Transitions::Event.new(nil, :event) do
14
14
  transitions :to => :closed, :from => [:open, :received]
15
15
  end
16
16
 
data/test/test_machine.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require "helper"
2
2
 
3
3
  class MachineTestSubject
4
- include StateMachine
4
+ include Transitions
5
5
 
6
6
  state_machine do
7
7
  state :open
@@ -22,7 +22,7 @@ class MachineTestSubject
22
22
  end
23
23
  end
24
24
 
25
- class StateMachineMachineTest < Test::Unit::TestCase
25
+ class TransitionsMachineTest < Test::Unit::TestCase
26
26
  test "allows reuse of existing machines" do
27
27
  assert_equal 2, MachineTestSubject.state_machines.size
28
28
  end
@@ -32,7 +32,7 @@ class StateMachineMachineTest < Test::Unit::TestCase
32
32
  end
33
33
 
34
34
  test "accesses non-default state machine" do
35
- assert_kind_of StateMachine::Machine, MachineTestSubject.state_machine(:extra)
35
+ assert_kind_of Transitions::Machine, MachineTestSubject.state_machine(:extra)
36
36
  end
37
37
 
38
38
  test "finds events for given state" do
data/test/test_state.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require "helper"
2
2
 
3
3
  class StateTestSubject
4
- include StateMachine
4
+ include Transitions
5
5
 
6
6
  state_machine do
7
7
  end
@@ -15,7 +15,7 @@ class TestState < Test::Unit::TestCase
15
15
  end
16
16
 
17
17
  def new_state(options={})
18
- StateMachine::State.new(@state_name, @options.merge(options))
18
+ Transitions::State.new(@state_name, @options.merge(options))
19
19
  end
20
20
 
21
21
  test "sets the name" do
@@ -3,7 +3,7 @@ require "helper"
3
3
  class TestStateTransition < Test::Unit::TestCase
4
4
  test "should set from, to, and opts attr readers" do
5
5
  opts = {:from => "foo", :to => "bar", :guard => "g"}
6
- st = StateMachine::StateTransition.new(opts)
6
+ st = Transitions::StateTransition.new(opts)
7
7
 
8
8
  assert_equal opts[:from], st.from
9
9
  assert_equal opts[:to], st.to
@@ -12,7 +12,7 @@ class TestStateTransition < Test::Unit::TestCase
12
12
 
13
13
  test "should pass equality check if from and to are the same" do
14
14
  opts = {:from => "foo", :to => "bar", :guard => "g"}
15
- st = StateMachine::StateTransition.new(opts)
15
+ st = Transitions::StateTransition.new(opts)
16
16
 
17
17
  obj = stub
18
18
  obj.stubs(:from).returns(opts[:from])
@@ -23,7 +23,7 @@ class TestStateTransition < Test::Unit::TestCase
23
23
 
24
24
  test "should fail equality check if from are not the same" do
25
25
  opts = {:from => "foo", :to => "bar", :guard => "g"}
26
- st = StateMachine::StateTransition.new(opts)
26
+ st = Transitions::StateTransition.new(opts)
27
27
 
28
28
  obj = stub
29
29
  obj.stubs(:from).returns("blah")
@@ -34,7 +34,7 @@ class TestStateTransition < Test::Unit::TestCase
34
34
 
35
35
  test "should fail equality check if to are not the same" do
36
36
  opts = {:from => "foo", :to => "bar", :guard => "g"}
37
- st = StateMachine::StateTransition.new(opts)
37
+ st = Transitions::StateTransition.new(opts)
38
38
 
39
39
  obj = stub
40
40
  obj.stubs(:from).returns(opts[:from])
@@ -3,14 +3,14 @@ require "helper"
3
3
  class TestStateTransitionGuardCheck < Test::Unit::TestCase
4
4
  test "should return true of there is no guard" do
5
5
  opts = {:from => "foo", :to => "bar"}
6
- st = StateMachine::StateTransition.new(opts)
6
+ st = Transitions::StateTransition.new(opts)
7
7
 
8
8
  assert st.perform(nil)
9
9
  end
10
10
 
11
11
  test "should call the method on the object if guard is a symbol" do
12
12
  opts = {:from => "foo", :to => "bar", :guard => :test_guard}
13
- st = StateMachine::StateTransition.new(opts)
13
+ st = Transitions::StateTransition.new(opts)
14
14
 
15
15
  obj = stub
16
16
  obj.expects(:test_guard)
@@ -20,7 +20,7 @@ class TestStateTransitionGuardCheck < Test::Unit::TestCase
20
20
 
21
21
  test "should call the method on the object if guard is a string" do
22
22
  opts = {:from => "foo", :to => "bar", :guard => "test_guard"}
23
- st = StateMachine::StateTransition.new(opts)
23
+ st = Transitions::StateTransition.new(opts)
24
24
 
25
25
  obj = stub
26
26
  obj.expects(:test_guard)
@@ -30,7 +30,7 @@ class TestStateTransitionGuardCheck < Test::Unit::TestCase
30
30
 
31
31
  test "should call the proc passing the object if the guard is a proc" do
32
32
  opts = {:from => "foo", :to => "bar", :guard => Proc.new {|o| o.test_guard}}
33
- st = StateMachine::StateTransition.new(opts)
33
+ st = Transitions::StateTransition.new(opts)
34
34
 
35
35
  obj = stub
36
36
  obj.expects(:test_guard)
data/transitions.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{transitions}
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jakub Kuźma"]
@@ -22,12 +22,12 @@ Gem::Specification.new do |s|
22
22
  "README.rdoc",
23
23
  "Rakefile",
24
24
  "VERSION",
25
- "lib/active_record/state_machine.rb",
26
- "lib/state_machine.rb",
27
- "lib/state_machine/event.rb",
28
- "lib/state_machine/machine.rb",
29
- "lib/state_machine/state.rb",
30
- "lib/state_machine/state_transition.rb",
25
+ "lib/active_record/transitions.rb",
26
+ "lib/transitions.rb",
27
+ "lib/transitions/event.rb",
28
+ "lib/transitions/machine.rb",
29
+ "lib/transitions/state.rb",
30
+ "lib/transitions/state_transition.rb",
31
31
  "test/helper.rb",
32
32
  "test/test_active_record.rb",
33
33
  "test/test_event.rb",
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 4
9
- version: 0.0.4
8
+ - 5
9
+ version: 0.0.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - "Jakub Ku\xC5\xBAma"
@@ -81,12 +81,12 @@ files:
81
81
  - README.rdoc
82
82
  - Rakefile
83
83
  - VERSION
84
- - lib/active_record/state_machine.rb
85
- - lib/state_machine.rb
86
- - lib/state_machine/event.rb
87
- - lib/state_machine/machine.rb
88
- - lib/state_machine/state.rb
89
- - lib/state_machine/state_transition.rb
84
+ - lib/active_record/transitions.rb
85
+ - lib/transitions.rb
86
+ - lib/transitions/event.rb
87
+ - lib/transitions/machine.rb
88
+ - lib/transitions/state.rb
89
+ - lib/transitions/state_transition.rb
90
90
  - test/helper.rb
91
91
  - test/test_active_record.rb
92
92
  - test/test_event.rb