dry-monads 0.2.0 → 0.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8b7637e82c392e9033203131fc8a142dbb3c70d
4
- data.tar.gz: accbe167e84adc328b782f52db264317396f0692
3
+ metadata.gz: f0acc62dda69a191664c47cae89550fa7e248b34
4
+ data.tar.gz: afd7e702a5dfb513b1f797890cdc465d5c1aaa57
5
5
  SHA512:
6
- metadata.gz: 2cba273461666107f402c9ef8ce31ad1c9924e6258b8cf4b16fc22439131084b31369fbce2c9c0c65339cb5d8bcf1e2c6b3076ca033e2e58bbe0bb8f3643d109
7
- data.tar.gz: 601ca3bc9b87390cfe54e8698142cf8ffed94019bb0ce7f5be29c39bcbb23142a475ea977591fc2d8849ac2e405e0570d1b8ade01dc599171da3635264709202
6
+ metadata.gz: cbfa1c6b7446d082f00539c7764becdccc2ccdcc6045d7ff2c4006aea2c98651ac189a4db88b3fb1585ded0b375597e08a9248827651d61350e581a6fd908b3b
7
+ data.tar.gz: 2f6116133861c76fc8f7975c8e44badd1c901de101fe4f91b9c7fe28242a89534fd1b1ae904481cd441a02bf76be9064377b1fac48b84142e843bce4ff9e19d4
data/.rubocop.yml CHANGED
@@ -58,3 +58,7 @@ Lint/Debugger:
58
58
  Lint/HandleExceptions:
59
59
  Exclude:
60
60
  - 'spec/spec_helper.rb'
61
+
62
+ Security/JSONLoad:
63
+ Exclude:
64
+ - 'spec/**/*'
data/.travis.yml CHANGED
@@ -1,17 +1,20 @@
1
1
  language: ruby
2
- sudo: false
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
- - rbx-2
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
@@ -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
- Maybe::Some.new(value)
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
  #
@@ -95,7 +95,7 @@ module Dry
95
95
  # Returns value. It exists to keep the interface identical to that of {Maybe::None}.
96
96
  #
97
97
  # @return [Object]
98
- def value_or(_val)
98
+ def value_or(_val = nil)
99
99
  value
100
100
  end
101
101
 
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module Monads
3
- VERSION = '0.2.0'.freeze
3
+ VERSION = '0.2.1'.freeze
4
4
  end
5
5
  end
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.0
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-09-18 00:00:00.000000000 Z
11
+ date: 2016-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-equalizer