mtrack 2.0.0 → 2.0.1
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.
- checksums.yaml +4 -4
- data/README.md +11 -11
- data/lib/mtrack/version.rb +1 -1
- data/tasks/coverage.rb +1 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa9cf6b841f88c763721244b23a30998ea8c4618
|
4
|
+
data.tar.gz: 0c6eb53464c8ce3a3643970fff927b50336351f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 532d2598f3f3b649ec3e119706ffeabd3f1d2d1abf7217143c7d3b51490a0b49d9ab23507e0231d22b8e261df59ec9ddeb53ec3649f42635da33bbfa8b26e389
|
7
|
+
data.tar.gz: 127f0f6e9ceef3acc7008aa24b64269d6239b9de04b7f398a0f52963456cc12c47b90a535a404b1fbb0699c59343d91ebc78d58f0b53b34430cbaa5ac884867a
|
data/README.md
CHANGED
@@ -118,15 +118,15 @@ class SimpleStateMachine
|
|
118
118
|
alias_method :allow_while, :track_methods
|
119
119
|
|
120
120
|
def actions(transitions)
|
121
|
-
transitions.each do |action,
|
122
|
-
define_method action, transition_implementation(action,
|
121
|
+
transitions.each do |action, new_state|
|
122
|
+
define_method action, transition_implementation(action, new_state)
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
126
|
def transition_implementation(action, new_state)
|
127
127
|
proc do
|
128
|
-
if self.class.tracked_methods(
|
129
|
-
self.
|
128
|
+
if self.class.tracked_methods(current_state).include? action
|
129
|
+
self.current_state = new_state
|
130
130
|
state_changed action
|
131
131
|
else
|
132
132
|
state_not_changed action
|
@@ -136,12 +136,12 @@ class SimpleStateMachine
|
|
136
136
|
end
|
137
137
|
|
138
138
|
def initialize(state)
|
139
|
-
self.
|
139
|
+
self.current_state = state
|
140
140
|
end
|
141
141
|
|
142
142
|
private
|
143
143
|
|
144
|
-
attr_accessor :
|
144
|
+
attr_accessor :current_state
|
145
145
|
end
|
146
146
|
```
|
147
147
|
|
@@ -153,12 +153,12 @@ class Box < SimpleStateMachine
|
|
153
153
|
super :locked
|
154
154
|
end
|
155
155
|
|
156
|
-
allow_while(:locked) { actions :
|
157
|
-
allow_while(:closed) { actions :
|
158
|
-
allow_while(:open) { actions :
|
156
|
+
allow_while(:locked) { actions unlock: :closed }
|
157
|
+
allow_while(:closed) { actions lock: :locked, open: :open }
|
158
|
+
allow_while(:open) { actions close: :closed }
|
159
159
|
|
160
160
|
def look
|
161
|
-
"The box is #{
|
161
|
+
"The box is #{current_state}."
|
162
162
|
end
|
163
163
|
|
164
164
|
private
|
@@ -168,7 +168,7 @@ class Box < SimpleStateMachine
|
|
168
168
|
end
|
169
169
|
|
170
170
|
def state_not_changed(action)
|
171
|
-
"You can't #{action} the box while it is #{
|
171
|
+
"You can't #{action} the box while it is #{current_state}!"
|
172
172
|
end
|
173
173
|
end
|
174
174
|
```
|
data/lib/mtrack/version.rb
CHANGED
data/tasks/coverage.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
desc "Run tests and generate coverage report"
|
2
2
|
task :coverage do
|
3
|
-
|
4
|
-
ENV["COVERAGE"] = "true"
|
5
|
-
else
|
6
|
-
warn "Ruby version 1.9+ is needed in order to generate coverage report."
|
7
|
-
end
|
3
|
+
ENV["COVERAGE"] = "true"
|
8
4
|
Rake::Task[:spec].invoke
|
9
5
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mtrack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel de Oliveira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
MTrack extends the functionality of modules and classes and enables them to define public methods within groups. These
|