rumonade 0.2.1 → 0.2.2

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.
data/HISTORY.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # HISTORY
2
2
 
3
+ ## v0.2.2 (Apr 26, 2012)
4
+
5
+ - added Either#+ to allow combining validations
6
+ - See full list @ https://github.com/ms-ati/rumonade/compare/v0.2.1...v0.2.2
7
+
3
8
  ## v0.2.1 (Oct 22, 2011)
4
9
 
5
10
  - fixed Option#map to disallow becoming None on a nil result
@@ -43,6 +43,16 @@ module Rumonade
43
43
  def right
44
44
  RightProjection.new(self)
45
45
  end
46
+
47
+ # @param [Either] other the either to combine with
48
+ # @return [Either] Returns a +Left+ with all Left values (if any), otherwise a +Right+ with all Right values
49
+ def +(other)
50
+ if [self, other].any?(&:left?)
51
+ Left([self, other].map { |either| either.left.to_opt }.flatten)
52
+ else
53
+ Right([self, other].map { |either| either.right.to_opt }.flatten)
54
+ end
55
+ end
46
56
  end
47
57
 
48
58
  # The left side of the disjoint union, as opposed to the Right side.
@@ -1,3 +1,3 @@
1
1
  module Rumonade
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
data/test/either_test.rb CHANGED
@@ -159,4 +159,9 @@ class EitherTest < Test::Unit::TestCase
159
159
  assert_equal "RightProjection(Left(error))", Left("error").right.to_s
160
160
  assert_equal "LeftProjection(Right(42))", Right(42).left.to_s
161
161
  end
162
+
163
+ def test_plus_for_left_and_right
164
+ assert_equal Left(["bad", "worse"]), Left("bad") + Right(:good) + Left("worse") + Right(:good)
165
+ assert_equal Right([:good, :better]), Right(:good) + Right(:better)
166
+ end
162
167
  end
metadata CHANGED
@@ -1,38 +1,40 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rumonade
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2
4
5
  prerelease:
5
- version: 0.2.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Marc Siegel
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-10-22 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2012-04-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: test-unit
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
24
22
  type: :development
25
- version_requirements: *id001
26
- description: A Scala-inspired Monad library for Ruby, aiming to share the most common idioms for folks working in both languages. Includes Option, Array, etc.
27
- email:
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: A Scala-inspired Monad library for Ruby, aiming to share the most common
31
+ idioms for folks working in both languages. Includes Option, Array, etc.
32
+ email:
28
33
  - marc@usainnov.com
29
34
  executables: []
30
-
31
35
  extensions: []
32
-
33
36
  extra_rdoc_files: []
34
-
35
- files:
37
+ files:
36
38
  - .gitignore
37
39
  - Gemfile
38
40
  - HISTORY.md
@@ -57,35 +59,33 @@ files:
57
59
  - test/test_helper.rb
58
60
  homepage: http://github.com/ms-ati/rumonade
59
61
  licenses: []
60
-
61
62
  post_install_message:
62
63
  rdoc_options: []
63
-
64
- require_paths:
64
+ require_paths:
65
65
  - lib
66
- required_ruby_version: !ruby/object:Gem::Requirement
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
67
  none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- version: "0"
72
- required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: "0"
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
78
  requirements: []
79
-
80
79
  rubyforge_project: rumonade
81
- rubygems_version: 1.8.8
80
+ rubygems_version: 1.8.21
82
81
  signing_key:
83
82
  specification_version: 3
84
83
  summary: A Scala-inspired Monad library for Ruby
85
- test_files:
84
+ test_files:
86
85
  - test/array_test.rb
87
86
  - test/either_test.rb
88
87
  - test/error_handling_test.rb
89
88
  - test/lazy_identity_test.rb
90
89
  - test/option_test.rb
91
90
  - test/test_helper.rb
91
+ has_rdoc: