deterministic 0.15.2 → 0.15.3

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
  SHA1:
3
- metadata.gz: 2bb331ad64697fbda8cb2892c271c1b00937ca3b
4
- data.tar.gz: e60e278a4d1eaf041def76a5cff7392e1d09fc44
3
+ metadata.gz: 70b4013b20820efd41949d10c8bcb0706b514d12
4
+ data.tar.gz: cdb7071c05a8001af91c10212a67eceede5106cb
5
5
  SHA512:
6
- metadata.gz: dbab4e73e30dac951e7c55dae5001c4c44a28eec39ecd3daced5fd11967dc184401534592eb50f0838b2794f37601c9cc078675f56989c500427088eead4b842
7
- data.tar.gz: 3e8021e1f03ec2e3d8e63b5d3b957109f1a1941048239480de9b0d1663d82a8d94de33b9c20bf697c7aef5b7b331435c8939f8f820693a2caebc9ebcf73f9441
6
+ metadata.gz: 30b231a3e818e90d9f49fc5b9932adafe969ccfe8e645cabda707f2e5a13b50efd0e2f07916accb82c53f64e5dd592d85aa2075d21b1859a598c56a7ed9ba91b
7
+ data.tar.gz: b81e77b351c2fb48c5debfc979db451e5f021bd7cf3d240d101e867e0ae6e9c65ceeb3dd285f88f7332fce58c68db8d0c906dd1734c16c229ba80964c6336de2
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Deterministic
2
+ [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/pzol/deterministic?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
2
3
 
3
4
  [![Gem Version](https://badge.fury.io/rb/deterministic.png)](http://badge.fury.io/rb/deterministic)
4
5
 
@@ -11,7 +11,7 @@ module Deterministic
11
11
  end
12
12
 
13
13
  def any?(expr)
14
- to_option(expr) { expr.nil? || not(expr.respond_to?(:empty?)) || expr.empty? }
14
+ to_option(expr) { expr.nil? || (expr.respond_to?(:empty?) && expr.empty?) }
15
15
  end
16
16
 
17
17
  def to_option(expr, &predicate)
@@ -49,6 +49,8 @@ module Deterministic
49
49
  is_a? Option::None
50
50
  end
51
51
 
52
+ alias :empty? :none?
53
+
52
54
  def value_or(n)
53
55
  match {
54
56
  Some(s) { s }
@@ -76,6 +76,15 @@ module Deterministic
76
76
  Failure(_) { |f| f } # implied other.success?
77
77
  }
78
78
  end
79
+
80
+ def try(proc=nil, &block)
81
+ map(proc, &block)
82
+ rescue => err
83
+ Result::Failure.new(err)
84
+ end
85
+
86
+ alias :>= :try
87
+
79
88
  }
80
89
  end
81
90
 
@@ -1,3 +1,3 @@
1
1
  module Deterministic
2
- VERSION = "0.15.2"
2
+ VERSION = "0.15.3"
3
3
  end
@@ -117,6 +117,7 @@ describe Deterministic::Option do
117
117
  expect(described_class.any?({})).to be_none
118
118
  expect(described_class.any?([1])).to eq Some([1])
119
119
  expect(described_class.any?({foo: 1})).to eq Some({foo: 1})
120
+ expect(described_class.any?(1)).to eq Some(1)
120
121
  end
121
122
 
122
123
  it "try!" do
@@ -143,7 +143,6 @@ describe Deterministic::Result do
143
143
 
144
144
  context ">= (try)" do
145
145
  it "try (>=) catches errors and wraps them as Failure" do
146
- pending "not implemented"
147
146
  def error(ctx)
148
147
  raise "error #{ctx}"
149
148
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deterministic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.2
4
+ version: 0.15.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Zolnierek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-01 00:00:00.000000000 Z
11
+ date: 2015-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler