wrapped 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
  Gemfile.lock
4
4
  pkg/*
5
5
  *swp
6
+ .rspec
@@ -63,4 +63,13 @@ class Blank
63
63
  def fmap
64
64
  self
65
65
  end
66
+
67
+ # Is this wrapped value equal to the given wrapped value? All blank values
68
+ # are equal to each other.
69
+ #
70
+ # > nil.wrapped == nil.wrapped
71
+ # > 1.wrapped == nil.wrapped
72
+ def ==(other)
73
+ other.blank?
74
+ end
66
75
  end
@@ -80,10 +80,18 @@ class Present
80
80
 
81
81
  # Run a block within the wrapper. This produces a wrapped value.
82
82
  #
83
- # > w.try {|n| n+1 }
83
+ # > w.fmap {|n| n+1 }
84
84
  #
85
85
  # This makes it a functor.
86
86
  def fmap
87
87
  (yield unwrap).wrapped
88
88
  end
89
+
90
+ # Is this wrapped value equal to the given wrapped value?
91
+ #
92
+ # > 1.wrapped == 1.wrapped
93
+ # > nil.wrapped == 2.wrapped
94
+ def ==(other)
95
+ unwrap == other.unwrap_or(nil)
96
+ end
89
97
  end
@@ -1,3 +1,3 @@
1
1
  module Wrapped
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -173,3 +173,25 @@ describe Wrapped, 'functor' do
173
173
  nothing.fmap {|n| n+1}.should be_blank
174
174
  end
175
175
  end
176
+
177
+ describe Wrapped, 'equality' do
178
+ it 'is equal with the same wrapped value' do
179
+ 1.wrapped.should == 1.wrapped
180
+ end
181
+
182
+ it 'is not equal with a different wrapped value' do
183
+ 1.wrapped.should_not == 2.wrapped
184
+ end
185
+
186
+ it 'is equal with two wrapped nils' do
187
+ nil.wrapped.should == nil.wrapped
188
+ end
189
+
190
+ it 'is not equal with a wrapped nil and a wrapped value' do
191
+ nil.wrapped.should_not == 1.wrapped
192
+ end
193
+
194
+ it 'is not equal with a wrapped value and a wrapped nil' do
195
+ 1.wrapped.should_not == nil.wrapped
196
+ end
197
+ end
@@ -7,7 +7,8 @@ Gem::Specification.new do |s|
7
7
  s.version = Wrapped::VERSION
8
8
  s.authors = ["Mike Burns"]
9
9
  s.email = ["mike@mike-burns.com"]
10
- s.homepage = ""
10
+ s.homepage = "http://github.com/mike-burns/wrapped"
11
+ s.license = 'BSD'
11
12
  s.summary = %q{The maybe functor for Ruby}
12
13
  s.description = %q{The unchecked nil is a dangerous concept leading to NoMethodErrors at runtime. It would be better if you were forced to explictly unwrap potentially nil values. This library provides mechanisms and convenience methods for making this more possible.}
13
14
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wrapped
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Mike Burns
@@ -15,11 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-29 00:00:00 Z
18
+ date: 2011-12-14 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: rspec
22
- prerelease: false
21
+ type: :development
23
22
  requirement: &id001 !ruby/object:Gem::Requirement
24
23
  none: false
25
24
  requirements:
@@ -29,11 +28,11 @@ dependencies:
29
28
  segments:
30
29
  - 0
31
30
  version: "0"
32
- type: :development
31
+ prerelease: false
32
+ name: rspec
33
33
  version_requirements: *id001
34
34
  - !ruby/object:Gem::Dependency
35
- name: rake
36
- prerelease: false
35
+ type: :development
37
36
  requirement: &id002 !ruby/object:Gem::Requirement
38
37
  none: false
39
38
  requirements:
@@ -43,7 +42,8 @@ dependencies:
43
42
  segments:
44
43
  - 0
45
44
  version: "0"
46
- type: :development
45
+ prerelease: false
46
+ name: rake
47
47
  version_requirements: *id002
48
48
  description: The unchecked nil is a dangerous concept leading to NoMethodErrors at runtime. It would be better if you were forced to explictly unwrap potentially nil values. This library provides mechanisms and convenience methods for making this more possible.
49
49
  email:
@@ -68,9 +68,9 @@ files:
68
68
  - spec/spec_helper.rb
69
69
  - spec/wrapped_spec.rb
70
70
  - wrapped.gemspec
71
- homepage: ""
72
- licenses: []
73
-
71
+ homepage: http://github.com/mike-burns/wrapped
72
+ licenses:
73
+ - BSD
74
74
  post_install_message:
75
75
  rdoc_options: []
76
76
 
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  requirements: []
98
98
 
99
99
  rubyforge_project:
100
- rubygems_version: 1.7.2
100
+ rubygems_version: 1.8.11
101
101
  signing_key:
102
102
  specification_version: 3
103
103
  summary: The maybe functor for Ruby