ribimaybe 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDI0OGM5YTQyNzcyMTE2N2Q1NWNhNjAxMjY3MmRmYzMyYTViNWFhYw==
4
+ NWIzYTk4OTMzOTZjZDA2MWNiNjEwMGVmNTNkZDI0Y2YzZDJiMzMxMA==
5
5
  data.tar.gz: !binary |-
6
- OTU3ZDdhMWJkNzliZDBjYWUyZTJiNzIzYTM2YmVmMjZhNjcyOWM3Nw==
6
+ ZWM1YzAwN2MyNjg4ZTM1NGUyMmY4Y2Q0ODhhOTgxYzMzOGMxZDMxYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzQ2ODU0OWI1MzE1OTQ5MGY3OTk0NjE1MTE2ZWZjMDc5YTI1Y2ZjODIzMjdj
10
- Njc3ODNkMGFlMDFiYzZhM2RhMWEzMGU3YjA3YWNlNDEwNjYwNDk3OTBkOGMw
11
- M2VlOWNlZjc0OTRjNjU0YWVhZTM0OTE1YWZiMDE4YzQxNWY5NWM=
9
+ ZTExNGRmM2JiOTVlZWM0YzdmMGRkYTYzZTJlYzRlODI3OGQ3MjRjYTVkZTA5
10
+ YmQ0ODQ3NDllNmE4NTU5MWExYjBlZGY5Mzk1ZTc2MzM1MTE0ZjUwNWM4ZWNm
11
+ MmJjYmZhNzI4NzBlMTQ1ODFjZjU0YjllYzcxYjkyNzVmYzVhNzQ=
12
12
  data.tar.gz: !binary |-
13
- YmNkNWVmYWExYjNiYmM1OTE5MTM3ZjVkN2VmYjE2ODAxZjMxNmM4NDA3ODI0
14
- OTQxNjhiNGZjMDM1M2YzZWFlZWMxMWFjMWUxYTM4YWIzOTJhNmIwNTMwYmFi
15
- NTFhNTI3ZTFlNjk4ZmNhY2FiNjQyMzEwZWEyMWU5Mzk1MmMxZjM=
13
+ ODc5NDZmZTJkZTEzYTJjYWI5NjU2ZTY4YzJiOGQ0ZjMxZjg5MTBkZDVmNTRk
14
+ M2QwZmE1NDY4YmEwZDljOGM2YmVkOGZmZWQ4NTJhZDM4NzRhZTI1OTkxMWZm
15
+ NDQzZTE1YzcyMGExMDczMTY1NDg5MjRkOTBhMWM1YzY1Y2E3NTU=
data/lib/ribimaybe.rb CHANGED
@@ -4,6 +4,11 @@ module Ribimaybe
4
4
  module Maybe
5
5
  include Contracts
6
6
 
7
+ # Hack to ensure constant is available to Ruby contracts.
8
+ #
9
+ module Nothing; end
10
+ class Just; end
11
+
7
12
  module Nothing
8
13
  include Contracts
9
14
 
@@ -15,6 +20,15 @@ module Ribimaybe
15
20
 
16
21
  alias_method :inspect, :to_s
17
22
 
23
+ # Compares a Just to another Maybe.
24
+ #
25
+ # ==== Attributes
26
+ #
27
+ Contract Or[Nothing, Just] => Bool
28
+ def self.===(other)
29
+ self == other
30
+ end
31
+
18
32
  # No operation. Always returns the default value.
19
33
  #
20
34
  Contract Any, Proc => Any
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ribimaybe
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
data/spec/bug_spec.rb CHANGED
@@ -11,4 +11,33 @@ describe "Bugs" do
11
11
  expect(result).to eq(Nothing)
12
12
  end
13
13
  end
14
+
15
+ describe "issue19" do
16
+ context "when i have nothing" do
17
+ it do
18
+ x = Nothing
19
+ result = case x
20
+ when Just
21
+ binding.pry
22
+ x.maybe(:x) { |x| x }
23
+ when Nothing
24
+ :nothing
25
+ end
26
+ expect(result).to eq(:nothing)
27
+ end
28
+ end
29
+
30
+ context "when i have just :x" do
31
+ it do
32
+ x = Just(:x)
33
+ result = case x
34
+ when Just
35
+ x.maybe(:x) { |x| x }
36
+ when Nothing
37
+ :nothing
38
+ end
39
+ expect(result).to eq(:x)
40
+ end
41
+ end
42
+ end
14
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ribimaybe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - unsymbol
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-11 00:00:00.000000000 Z
11
+ date: 2014-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler