state_manager 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8d8f1d38c94644635476694a05bf9f5461753058
4
+ data.tar.gz: b715e0342ff1faedb8cfc03c03afa5d289dd985d
5
+ SHA512:
6
+ metadata.gz: 3d0b6c7cb6fde30f0d7a0aad17c59714dc48fa66546e274c2504baa0d16189474f9424cc6d42db15846890c869ff9bcd2b482691111bfd25e4edbf6c5d1b11aa
7
+ data.tar.gz: 33fe78f700bf67b646b120d945782e75b1537b214c74945c6c00a0b94bb7b9d8eda93acdc3de22bed91d0df4abe75e13c05da968c36492aaf83b018427f077d2
data/Gemfile CHANGED
@@ -9,4 +9,5 @@ group :development do
9
9
  gem 'sqlite3'
10
10
  gem 'timecop'
11
11
  gem 'database_cleaner'
12
+ gem 'byebug'
12
13
  end
@@ -73,6 +73,7 @@ module StateManager
73
73
 
74
74
  def run_after_callbacks(*args)
75
75
  end
76
+
76
77
  end
77
78
  end
78
79
 
@@ -83,9 +83,11 @@ module StateManager
83
83
  end
84
84
 
85
85
  def send_event!(name, *args)
86
- result = send_event(name, *args)
87
- persist_state
88
- result
86
+ around_event(name, *args) do
87
+ result = send_event(name, *args)
88
+ persist_state
89
+ result
90
+ end
89
91
  end
90
92
 
91
93
  def send_event(name, *args)
@@ -153,6 +155,10 @@ module StateManager
153
155
 
154
156
  def did_transition(from, to, event)
155
157
  end
158
+
159
+ def around_event(event, *args, &block)
160
+ yield
161
+ end
156
162
 
157
163
  # All events the current state will respond to
158
164
  def available_events
@@ -1,3 +1,3 @@
1
1
  module StateManager
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
data/test/basic_test.rb CHANGED
@@ -5,6 +5,12 @@ class BasicTest < Minitest::Test
5
5
  class PostStates < StateManager::Base
6
6
 
7
7
  attr_accessor :title
8
+ attr_accessor :around_hit
9
+
10
+ def initialize(*args)
11
+ super
12
+ @around_hit = 0
13
+ end
8
14
 
9
15
  state :unsubmitted do
10
16
  event :submit, :transitions_to => 'submitted.awaiting_review'
@@ -29,6 +35,11 @@ class BasicTest < Minitest::Test
29
35
  state_manager.title = title
30
36
  end
31
37
  end
38
+
39
+ def around_event(name, *args)
40
+ @around_hit += 1
41
+ yield
42
+ end
32
43
 
33
44
  end
34
45
 
@@ -156,4 +167,9 @@ class BasicTest < Minitest::Test
156
167
  assert_equal 'some title', @resource.state_manager.title
157
168
  end
158
169
 
170
+ def test_around_event
171
+ @resource.state_manager.send_event! :submit
172
+ assert_equal 1, @resource.state_manager.around_hit
173
+ end
174
+
159
175
  end
data/test/helper.rb CHANGED
@@ -15,6 +15,7 @@ require 'delayed_job_active_record'
15
15
  require 'state_manager'
16
16
  require 'timecop'
17
17
  require 'database_cleaner'
18
+ require 'byebug'
18
19
 
19
20
  DatabaseCleaner.strategy = :truncation
20
21
 
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: state_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
5
- prerelease:
4
+ version: 0.3.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Gordon L. Hempton
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-06-30 00:00:00.000000000 Z
11
+ date: 2015-01-13 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activesupport
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ">="
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: bundler
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - "~>"
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - "~>"
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ">="
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ">="
60
53
  - !ruby/object:Gem::Version
@@ -98,27 +91,26 @@ files:
98
91
  homepage: https://github.com/ghempton/state_manager
99
92
  licenses:
100
93
  - MIT
94
+ metadata: {}
101
95
  post_install_message:
102
96
  rdoc_options: []
103
97
  require_paths:
104
98
  - lib
105
99
  required_ruby_version: !ruby/object:Gem::Requirement
106
- none: false
107
100
  requirements:
108
101
  - - ">="
109
102
  - !ruby/object:Gem::Version
110
103
  version: '0'
111
104
  required_rubygems_version: !ruby/object:Gem::Requirement
112
- none: false
113
105
  requirements:
114
106
  - - ">="
115
107
  - !ruby/object:Gem::Version
116
108
  version: '0'
117
109
  requirements: []
118
110
  rubyforge_project:
119
- rubygems_version: 1.8.25
111
+ rubygems_version: 2.2.2
120
112
  signing_key:
121
- specification_version: 3
113
+ specification_version: 4
122
114
  summary: "%Q{Finite state machine implementation.}"
123
115
  test_files:
124
116
  - test/adapters/active_record_test.rb