statefully 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ab676bd0fdc9e9d6b17d8c606aa381e9aeab8cac
4
- data.tar.gz: 11c77ad8e395dac8b413606ce8e7698b4482c27b
2
+ SHA256:
3
+ metadata.gz: 133314844a98c7934bd388ac9a25bf4c5b6f8532e56936c3881bf964c10a96b1
4
+ data.tar.gz: c2b9d739224fe5bc7af794c08d5afce6d6b95e6bea30c7284549fb2a66eb0432
5
5
  SHA512:
6
- metadata.gz: a6dcbb610b68d77357d1f4a015cadb5c33430b763ea244bacc6bf2d9748356bb7576ec5154b6c3c4840248bac1df85b1f45134ad11c1e99c011510fd8cd2e024
7
- data.tar.gz: '0543961fa3864e71e1c647c8f1d1176ee1ad6bdfd420dd8a2336358f8f2e65b3c5a4c6458815a85c64c10f82aa4c14919a5a5b5de4d4d456bfa0d847eec9cc92'
6
+ metadata.gz: 74e86d22ffffc5a45407c957067810e7c496b5a1b57d524eefb2f51c15bd6dab2c7b0d6524b90e52df5f476a9f4a5c0e872f39b5b6148306848ffe677415db07
7
+ data.tar.gz: d7a7dc1ae4899eba2caa6328ca78acabafda24d7f149134089905ea68204c65537d8692dc0de2319d524cdd8f95b57841206ed8dc177cc363972c6c35cbb00a6
@@ -61,7 +61,7 @@ module Statefully
61
61
  #
62
62
  # @param values [Hash<Symbol, Object>] keyword arguments
63
63
  #
64
- # @return [type] [description]
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>]
@@ -1,3 +1,3 @@
1
1
  module Statefully
2
- VERSION = '0.1.7'.freeze
2
+ VERSION = '0.1.8'.freeze
3
3
  end
@@ -62,7 +62,15 @@ module Statefully
62
62
  it { expect(state).not_to be_finished }
63
63
  end
64
64
 
65
- describe 'history' do
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.7
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: 2017-12-22 00:00:00.000000000 Z
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.6.13
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