statefully 0.1 → 0.1.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/lib/statefully/diff.rb +1 -1
- data/lib/statefully/state.rb +6 -1
- data/spec/state_spec.rb +3 -0
- 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: fbde1d672d9e234ef6437588fc07a363f48045b9
|
|
4
|
+
data.tar.gz: f39ccf8385e78a68c4347e480d221f377037c098
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7a255b7ca151f1fa64ebf9f46cda4ba21a83403bdf18d70e276b2d1d68d60d31a27f5c6a463053f8647da55e566914629b3386beb257f58c4f3d8669bf9001be
|
|
7
|
+
data.tar.gz: b74b2c98d7935cbb0be0e610120d790ec7accaef99e05f0a3911e0a682dbad28778a59ffd5e039889b4d9223cac2d97da9a384cbe7047b8d6135374185377ea5
|
data/lib/statefully/diff.rb
CHANGED
data/lib/statefully/state.rb
CHANGED
|
@@ -3,10 +3,11 @@ require 'singleton'
|
|
|
3
3
|
|
|
4
4
|
module Statefully
|
|
5
5
|
class State
|
|
6
|
+
include Enumerable
|
|
6
7
|
extend Forwardable
|
|
7
8
|
|
|
8
9
|
attr_reader :previous
|
|
9
|
-
def_delegators :@_members, :key?, :keys, :fetch
|
|
10
|
+
def_delegators :@_members, :each, :key?, :keys, :fetch
|
|
10
11
|
|
|
11
12
|
def self.create(**values)
|
|
12
13
|
Success.send(:new, values, previous: None.instance).freeze
|
|
@@ -24,6 +25,10 @@ module Statefully
|
|
|
24
25
|
true
|
|
25
26
|
end
|
|
26
27
|
|
|
28
|
+
def failure?
|
|
29
|
+
!success?
|
|
30
|
+
end
|
|
31
|
+
|
|
27
32
|
def resolve
|
|
28
33
|
self
|
|
29
34
|
end
|
data/spec/state_spec.rb
CHANGED
|
@@ -16,6 +16,7 @@ module Statefully
|
|
|
16
16
|
describe 'methods delegated to the underlying Hash' do
|
|
17
17
|
it { expect(subject.keys).to eq [:old_key] }
|
|
18
18
|
it { expect(subject.key?(:old_key)).to be_truthy }
|
|
19
|
+
it { expect(subject.any? { |_, value| value == val }).to be_truthy }
|
|
19
20
|
end # describe 'methods delegated to the underlying Hash'
|
|
20
21
|
|
|
21
22
|
describe "methods dynamically dispatched using 'method_missing'" do
|
|
@@ -31,6 +32,7 @@ module Statefully
|
|
|
31
32
|
describe 'trivial readers' do
|
|
32
33
|
it { expect(subject.resolve).to eq subject }
|
|
33
34
|
it { expect(subject).to be_success }
|
|
35
|
+
it { expect(subject).not_to be_failure }
|
|
34
36
|
end # describe 'trivial readers'
|
|
35
37
|
|
|
36
38
|
describe '#succeed' do
|
|
@@ -58,6 +60,7 @@ module Statefully
|
|
|
58
60
|
let(:failed) { subject.fail(error) }
|
|
59
61
|
|
|
60
62
|
it { expect(failed).not_to be_success }
|
|
63
|
+
it { expect(failed).to be_failure }
|
|
61
64
|
it { expect(failed.old_key).to eq val }
|
|
62
65
|
it { expect(failed.previous).to eq subject }
|
|
63
66
|
it { expect(failed.error).to eq error }
|
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:
|
|
4
|
+
version: 0.1.1
|
|
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-05-
|
|
11
|
+
date: 2017-05-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|