ronad 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1c1d81e3ad943c14948fd34fdc398b803c448c539caae98c4185a6d755f0f1b
4
- data.tar.gz: 92dab46b61f572cc282250c82a0ab773ced2ebe324a0afca5c62f583514aae09
3
+ metadata.gz: 92c3fe5954c20636ef0adfda0823d73b1c3c91a9778bc6698d9be5538c22d402
4
+ data.tar.gz: de98fafde865cb62229efb3163c708349f15d2922e6cb860c75c6f69a005b9cd
5
5
  SHA512:
6
- metadata.gz: 0a2e89de7f169d6151ad8206c44b36092d30bbe307d1ec2b173cdb867039846b94e8799c55fc2f9e091151da4888630126be9a548a4285a59691baf70d5c52ed
7
- data.tar.gz: bce45b736e66c1a22735af3d42582233104705d71f5ab376a18008850d0fa6eebc2a63c0317b9f581a3d6c11fefed5a459654f69945931b03519c2433e05f01c
6
+ metadata.gz: d7da852fd7409736474db7734b38fb2ea2caa558830a26c12499bc6ede51bb8c59c24c896f344c24c3070dc3483015cdce40789eb6b14ea655a89028479b395b
7
+ data.tar.gz: 99b5d6de76fb2f78e204284170e71eccf792a6108421cc3cccc705eb4d31f685e284d003f90d6c7cd12a6f8b322d175acd7c344321dd2e6ff372cd67cb235f36
data/bin/console CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "bundler/setup"
4
4
  require "ronad"
5
+ require "ronad/sugar"
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -1,7 +1,12 @@
1
1
  module Ronad
2
+ # @deprecated
3
+ # @see Ronad::Maybe::from_multiple_values
2
4
  class JustOne < Just
3
- def initialize(*args)
4
- super args.detect { |v| Monad === v ? v.value : v }
5
+ def self.new(*args)
6
+ warn "[DEPRECATION] Ronad::JustOne is deprecated, see Ronad::Many::from_multiple_values."
7
+ raise CannotBeNil if args.compact.empty?
8
+
9
+ Just.new Maybe.from_multiple_values(*args)
5
10
  end
6
11
  end
7
12
  end
data/lib/ronad/maybe.rb CHANGED
@@ -2,6 +2,12 @@ require 'ronad/monad'
2
2
 
3
3
  module Ronad
4
4
  class Maybe < Monad
5
+ # Creates a single Maybe from multiple values, shorting on the first
6
+ # non-nil value.
7
+ def self.from_multiple_values(*vals)
8
+ new vals.detect { |v| Monad.new(v).value != nil }
9
+ end
10
+
5
11
  # Allows for safe navigation on nil.
6
12
  #
7
13
  # nil&.m1&.m2&.m3 #=> nil
data/lib/ronad/sugar.rb CHANGED
@@ -4,7 +4,7 @@ require 'ronad/just_one'
4
4
  require 'ronad/default'
5
5
  require 'ronad/eventually'
6
6
 
7
- def Maybe(value) ; Ronad::Maybe.new(value) end
7
+ def Maybe(*values) ; Ronad::Maybe.from_multiple_values(*values) end
8
8
  def Just(value); Ronad::Just.new(value) end
9
9
  def JustOne(*values); Ronad::JustOne.new(*values) end
10
10
  def Default(fallback, value) ; Ronad::Default.new(fallback, value) end
data/lib/ronad/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ronad
2
- VERSION = '0.8.0'
2
+ VERSION = '0.9.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ronad
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uri Gorelik
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-22 00:00:00.000000000 Z
11
+ date: 2018-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler