statefully 0.1.7 → 0.1.8
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 +5 -5
- data/lib/statefully/state.rb +23 -1
- data/lib/statefully/version.rb +1 -1
- data/spec/state_spec.rb +9 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 133314844a98c7934bd388ac9a25bf4c5b6f8532e56936c3881bf964c10a96b1
|
4
|
+
data.tar.gz: c2b9d739224fe5bc7af794c08d5afce6d6b95e6bea30c7284549fb2a66eb0432
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74e86d22ffffc5a45407c957067810e7c496b5a1b57d524eefb2f51c15bd6dab2c7b0d6524b90e52df5f476a9f4a5c0e872f39b5b6148306848ffe677415db07
|
7
|
+
data.tar.gz: d7a7dc1ae4899eba2caa6328ca78acabafda24d7f149134089905ea68204c65537d8692dc0de2319d524cdd8f95b57841206ed8dc177cc363972c6c35cbb00a6
|
data/lib/statefully/state.rb
CHANGED
@@ -61,7 +61,7 @@ module Statefully
|
|
61
61
|
#
|
62
62
|
# @param values [Hash<Symbol, Object>] keyword arguments
|
63
63
|
#
|
64
|
-
# @return [
|
64
|
+
# @return [State::Success] new successful State
|
65
65
|
# @api public
|
66
66
|
# @example
|
67
67
|
# Statefully::State.create(key: 'val')
|
@@ -71,6 +71,17 @@ module Statefully
|
|
71
71
|
Success.send(:new, base.merge(values), previous: None.instance).freeze
|
72
72
|
end
|
73
73
|
|
74
|
+
# Return all States that came before
|
75
|
+
#
|
76
|
+
# @return [Array<State>]
|
77
|
+
# @api public
|
78
|
+
# @example
|
79
|
+
# state = Statefully::State.create
|
80
|
+
# => [#<Statefully::State::None>]
|
81
|
+
def ancestry
|
82
|
+
[previous] + previous.ancestry
|
83
|
+
end
|
84
|
+
|
74
85
|
# Return a {Diff} between current and previous {State}
|
75
86
|
#
|
76
87
|
# @return [Diff]
|
@@ -290,6 +301,17 @@ module Statefully
|
|
290
301
|
class None < State
|
291
302
|
include Singleton
|
292
303
|
|
304
|
+
# Base case - {None} state does not have any ancestry
|
305
|
+
#
|
306
|
+
# @return [Array<State>]
|
307
|
+
# @api public
|
308
|
+
# @example
|
309
|
+
# Statefully::State::None.instance.ancestry
|
310
|
+
# => []
|
311
|
+
def ancestry
|
312
|
+
[]
|
313
|
+
end
|
314
|
+
|
293
315
|
# Return all historical changes to this {State}
|
294
316
|
#
|
295
317
|
# @return [Array<Diff>]
|
data/lib/statefully/version.rb
CHANGED
data/spec/state_spec.rb
CHANGED
@@ -62,7 +62,15 @@ module Statefully
|
|
62
62
|
it { expect(state).not_to be_finished }
|
63
63
|
end
|
64
64
|
|
65
|
-
describe '
|
65
|
+
describe '#ancestry' do
|
66
|
+
let(:ancestry) { state.succeed.ancestry }
|
67
|
+
|
68
|
+
it { expect(ancestry.count).to eq 2 }
|
69
|
+
it { expect(ancestry.first).to eq state }
|
70
|
+
it { expect(ancestry.last).to be_none }
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '#history' do
|
66
74
|
let(:history) { state.history }
|
67
75
|
|
68
76
|
it { expect(history.length).to eq 1 }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statefully
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcin Wyszynski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -264,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
264
264
|
version: '0'
|
265
265
|
requirements: []
|
266
266
|
rubyforge_project:
|
267
|
-
rubygems_version: 2.
|
267
|
+
rubygems_version: 2.7.4
|
268
268
|
signing_key:
|
269
269
|
specification_version: 4
|
270
270
|
summary: Immutable state with helpers to build awesome things
|