rmaybe 1.0.0 → 1.0.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.
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Build Status](https://travis-ci.org/kmdsbng/rmaybe.svg?branch=master)](https://travis-ci.org/kmdsbng/rmaybe)
4
4
  [![Gem Version](https://badge.fury.io/rb/rmaybe.png)](http://badge.fury.io/rb/rmaybe)
5
5
 
6
- This library gives maybe monad on ruby.
6
+ This library gives maybe monad on Ruby.
7
7
 
8
8
  ## Installation
9
9
 
@@ -21,7 +21,7 @@ Or install it yourself as:
21
21
 
22
22
  ## Usage
23
23
 
24
- "a b c".maybe.split[2].upcase.end #=> C
24
+ "a b c".maybe.split[2].upcase.end #=> "C"
25
25
 
26
26
  "a b c".maybe.split[3].upcase.end #=> nil
27
27
 
@@ -34,3 +34,7 @@ Or install it yourself as:
34
34
  4. Push to the branch (`git push origin my-new-feature`)
35
35
  5. Create new Pull Request
36
36
 
37
+
38
+ ## License
39
+
40
+ This project rocks and uses MIT-LICENSE.
@@ -1,3 +1,3 @@
1
1
  module Rmaybe
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
data/lib/rmaybe.rb CHANGED
@@ -7,7 +7,7 @@ class Never
7
7
  undef_method(v) unless %w(object_id __id__ __send__).include?(v.to_s)
8
8
  end
9
9
 
10
- def method_missing(*args)
10
+ def method_missing(*_args)
11
11
  self
12
12
  end
13
13
 
@@ -30,7 +30,7 @@ class Maybe < Never
30
30
  end
31
31
 
32
32
  def method_missing(*args, &block)
33
- @value ? Maybe.new(@value.__send__(*args, &block)) : Never.new
33
+ @value.nil? ? Never.new : Maybe.new(@value.__send__(*args, &block))
34
34
  end
35
35
 
36
36
  def end
@@ -40,9 +40,7 @@ end
40
40
 
41
41
  class Object
42
42
  def maybe
43
- Maybe.new(block_given? ? yield : self)
44
- rescue Exception
45
- Never.new
43
+ self.nil? ? Never.new : Maybe.new(block_given? ? yield : self)
46
44
  end
47
45
 
48
46
  def maybe?
@@ -10,15 +10,16 @@ describe 'maybe' do
10
10
 
11
11
  it 'nil.any_method return nil' do
12
12
  [0].maybe[1].next.end.should eq(nil)
13
-
14
13
  end
15
14
 
16
15
  it 'throws no method error' do
17
16
  lambda {
18
17
  Rational(2, 5).maybe.invalid_method.end
19
18
  }.should raise_error(NoMethodError)
20
-
21
19
  end
22
20
 
21
+ it 'nil.maybe should work' do
22
+ nil.maybe.hoge.moge.end.should eq(nil)
23
+ end
23
24
  end
24
25
 
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmaybe
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - kmdsbng
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-03-28 00:00:00.000000000 Z
12
+ date: 2015-02-25 00:00:00.000000000 Z
12
13
  dependencies: []
13
14
  description: maybe monad library
14
15
  email:
@@ -17,9 +18,9 @@ executables: []
17
18
  extensions: []
18
19
  extra_rdoc_files: []
19
20
  files:
20
- - ".gitignore"
21
- - ".rspec"
22
- - ".travis.yml"
21
+ - .gitignore
22
+ - .rspec
23
+ - .travis.yml
23
24
  - Gemfile
24
25
  - LICENSE.txt
25
26
  - README.md
@@ -31,26 +32,27 @@ files:
31
32
  - spec/spec_helper.rb
32
33
  homepage: ''
33
34
  licenses: []
34
- metadata: {}
35
35
  post_install_message:
36
36
  rdoc_options: []
37
37
  require_paths:
38
38
  - lib
39
39
  required_ruby_version: !ruby/object:Gem::Requirement
40
+ none: false
40
41
  requirements:
41
- - - ">="
42
+ - - ! '>='
42
43
  - !ruby/object:Gem::Version
43
44
  version: '0'
44
45
  required_rubygems_version: !ruby/object:Gem::Requirement
46
+ none: false
45
47
  requirements:
46
- - - ">="
48
+ - - ! '>='
47
49
  - !ruby/object:Gem::Version
48
50
  version: '0'
49
51
  requirements: []
50
52
  rubyforge_project:
51
- rubygems_version: 2.2.2
53
+ rubygems_version: 1.8.23
52
54
  signing_key:
53
- specification_version: 4
55
+ specification_version: 3
54
56
  summary: maybe monad library
55
57
  test_files:
56
58
  - spec/core/basic_usage_spec.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: afc34b6af201e824e1ab249c6eb15af786b5210d
4
- data.tar.gz: 9a026a17bcef0a257b975f9db2382bf7ab089a2d
5
- SHA512:
6
- metadata.gz: d7f051c18a6d42034ed7a860067687bbb43df2540199102774289fa6b1ca5671c0d2c8fba707587cfb79af002dd7c3a5c9d04eb50c6b2a3ec63bd726349ea592
7
- data.tar.gz: 36e831c0063a33bf2cb3efb903e2504f6fb5422fac42959b376c654b6732f024679340ac5632252c0f1c0059b3c5ddffaf2ddf92ccf8793afc6d102f61dd8d4d