dry-monads 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/.travis.yml +7 -3
- data/lib/dry/monads/either.rb +23 -1
- data/lib/dry/monads/maybe.rb +1 -1
- data/lib/dry/monads/version.rb +1 -1
- 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: f0acc62dda69a191664c47cae89550fa7e248b34
|
4
|
+
data.tar.gz: afd7e702a5dfb513b1f797890cdc465d5c1aaa57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbfa1c6b7446d082f00539c7764becdccc2ccdcc6045d7ff2c4006aea2c98651ac189a4db88b3fb1585ded0b375597e08a9248827651d61350e581a6fd908b3b
|
7
|
+
data.tar.gz: 2f6116133861c76fc8f7975c8e44badd1c901de101fe4f91b9c7fe28242a89534fd1b1ae904481cd441a02bf76be9064377b1fac48b84142e843bce4ff9e19d4
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|
language: ruby
|
2
|
-
|
2
|
+
dist: trusty
|
3
|
+
sudo: required
|
3
4
|
cache: bundler
|
4
5
|
bundler_args: --without benchmarks
|
5
6
|
script:
|
6
7
|
- bundle exec rake spec
|
7
8
|
- bundle exec rubocop
|
9
|
+
after_success:
|
10
|
+
- '[ "$TRAVIS_RUBY_VERSION" = "2.3.1" ] && [ "$TRAVIS_BRANCH" = "master" ] && bundle exec codeclimate-test-reporter'
|
8
11
|
rvm:
|
9
12
|
- 2.1.10
|
10
13
|
- 2.2.5
|
11
14
|
- 2.3.1
|
12
|
-
-
|
13
|
-
- jruby-9.1.1.0
|
15
|
+
- jruby-9.1.5.0
|
14
16
|
- ruby-head
|
17
|
+
- rbx-3
|
15
18
|
env:
|
16
19
|
global:
|
17
20
|
- JRUBY_OPTS='--dev -J-Xmx1024M'
|
@@ -21,6 +24,7 @@ matrix:
|
|
21
24
|
allow_failures:
|
22
25
|
- rvm: ruby-head
|
23
26
|
- rvm: jruby-head
|
27
|
+
- rvm: rbx-3
|
24
28
|
include:
|
25
29
|
- rvm: jruby-head
|
26
30
|
before_install: gem install bundler --no-ri --no-rdoc
|
data/lib/dry/monads/either.rb
CHANGED
@@ -74,6 +74,19 @@ module Dry
|
|
74
74
|
Right.new(bind(*args, &block))
|
75
75
|
end
|
76
76
|
|
77
|
+
# Does the same thing as #bind except it returns the original monad
|
78
|
+
# when the result is a Right.
|
79
|
+
#
|
80
|
+
# @example
|
81
|
+
# Dry::Monads.Right(4).tee { Right('ok') } # => Right(4)
|
82
|
+
# Dry::Monads.Right(4).tee { Left('fail') } # => Left('fail')
|
83
|
+
#
|
84
|
+
# @param [Array<Object>] args arguments will be transparently passed through to #bind
|
85
|
+
# @return [Either]
|
86
|
+
def tee(*args, &block)
|
87
|
+
bind(*args, &block).bind { self }
|
88
|
+
end
|
89
|
+
|
77
90
|
# Ignores arguments and returns self. It exists to keep the interface
|
78
91
|
# identical to that of {Either::Left}.
|
79
92
|
#
|
@@ -90,7 +103,8 @@ module Dry
|
|
90
103
|
|
91
104
|
# @return [Maybe::Some]
|
92
105
|
def to_maybe
|
93
|
-
|
106
|
+
Kernel.warn 'Right(nil) transformed to None' if value.nil?
|
107
|
+
Dry::Monads::Maybe(value)
|
94
108
|
end
|
95
109
|
end
|
96
110
|
|
@@ -121,6 +135,14 @@ module Dry
|
|
121
135
|
self
|
122
136
|
end
|
123
137
|
|
138
|
+
# Ignores the input parameter and returns self. It exists to keep the interface
|
139
|
+
# identical to that of {Either::Right}.
|
140
|
+
#
|
141
|
+
# @return [Either::Left]
|
142
|
+
def tee(*)
|
143
|
+
self
|
144
|
+
end
|
145
|
+
|
124
146
|
# If a block is given passes internal value to it and returns the result,
|
125
147
|
# otherwise simply returns the parameter val.
|
126
148
|
#
|
data/lib/dry/monads/maybe.rb
CHANGED
data/lib/dry/monads/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-monads
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikita Shilnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-equalizer
|