just_maybe 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/just_maybe/just.rb +0 -4
- data/lib/just_maybe/nothing.rb +0 -7
- data/lib/just_maybe/version.rb +1 -1
- data/lib/just_maybe.rb +1 -1
- data/spec/just_spec.rb +5 -6
- 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: 72ef2ce85b41d39244227cb4c844a34a32e4eb12
|
4
|
+
data.tar.gz: 9e82969ab7e6fd4f117f686cf9605d0eb745282b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 369988e0deb62bad303c334d60ffa9624882498d23dabfd91b351ab511097a1338f64c1dac8418b05546385fd795daf6c62e8194f713ab5242a00026bc06a40e
|
7
|
+
data.tar.gz: df965b85481a20aa6a68c3e1b7a529e7ec7b9b1aefc45549bd2f565b07ef2ed925d9f507e041759df1d1c19889d410de70f611a1ec299ac3323bd8c3d8a1f081
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#
|
1
|
+
# Just Maybe
|
2
2
|
|
3
3
|
An implementation of the "Maybe" pattern.
|
4
4
|
|
5
|
-
The philosophy of this particular implementation of the Maybe pattern is that you should use the `Maybe` function to wrap values before returning them from any method that could potentially return nil
|
5
|
+
The philosophy of this particular implementation of the Maybe pattern is that you should use the `Maybe` function to wrap values before returning them from any method that could potentially return `nil`. This forces the consumer of the returned object to pro-actively acknowledge that it could be `nil` by forcing them to use the `try` method to access it.
|
6
6
|
|
7
7
|
This implementation also does no monkey patching and does not rely on method missing or any other Ruby magic for it's implementation.
|
8
8
|
|
data/lib/just_maybe/just.rb
CHANGED
data/lib/just_maybe/nothing.rb
CHANGED
data/lib/just_maybe/version.rb
CHANGED
data/lib/just_maybe.rb
CHANGED
data/spec/just_spec.rb
CHANGED
@@ -3,20 +3,19 @@ require 'just_maybe/just'
|
|
3
3
|
describe Just do
|
4
4
|
|
5
5
|
it "just 'anything' is something" do
|
6
|
-
expect(Just('anything')).to be_something
|
6
|
+
expect(Just.new('anything')).to be_something
|
7
7
|
end
|
8
8
|
|
9
9
|
it "just 'anything' is not nothing" do
|
10
|
-
expect(Just('anything')).not_to be_nothing
|
11
|
-
expect(Just(nil)).not_to be_nothing
|
10
|
+
expect(Just.new('anything')).not_to be_nothing
|
12
11
|
end
|
13
12
|
|
14
13
|
it "just nil is something and not nothing" do
|
15
|
-
expect(Just(nil)).to be_something
|
16
|
-
expect(Just(nil)).not_to be_nothing
|
14
|
+
expect(Just.new(nil)).to be_something
|
15
|
+
expect(Just.new(nil)).not_to be_nothing
|
17
16
|
end
|
18
17
|
|
19
18
|
it "just 'anything' yields once with 'anything' to try" do
|
20
|
-
expect(Just('anything').try{|o| o.reverse }).to eq('gnihtyna')
|
19
|
+
expect(Just.new('anything').try{|o| o.reverse }).to eq('gnihtyna')
|
21
20
|
end
|
22
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: just_maybe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Greenly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple implmenetation of the Maybe pattern
|
14
14
|
email:
|