may_nil 0.0.1 → 0.1.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 +7 -0
- data/lib/may_nil.rb +9 -1
- metadata +7 -9
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 82d9437d80ec1f770dfe91dbfd5b30ffcce97209
|
|
4
|
+
data.tar.gz: 4e358fed56cbab6a7186ffb3d861431a5198b7a5
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: f3176fd00a0d9cab798c366abd03f08d2c70330750aa89eb630fad396b01263c1c06a89e2c903c599c968e8af7894ae8ed649f8df6c8d3ed0f5a18ce9bc9e27a
|
|
7
|
+
data.tar.gz: fd546236c3c0e812b93abf29ad4928a2f760001483d874c6a8310e4e39193c9444a1f2cf7abb3b71a4ce96eb31101f6eeb74533fac0cd7fd280f92333676b520
|
data/lib/may_nil.rb
CHANGED
|
@@ -7,10 +7,18 @@
|
|
|
7
7
|
# may_nil{ 0.foo.bar[2].baz } => Exception: NoMethodError
|
|
8
8
|
#
|
|
9
9
|
|
|
10
|
+
class NoMethodError
|
|
11
|
+
def may_nil_missing_source
|
|
12
|
+
if /undefined local variable or method/ !~ message
|
|
13
|
+
$1 if /((::)?([A-Z]\w*)(::[A-Z]\w*)*)$/ =~ message
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
10
18
|
def may_nil &blk
|
|
11
19
|
blk.call
|
|
12
20
|
rescue NoMethodError => e
|
|
13
|
-
raise if e.
|
|
21
|
+
raise if e.may_nil_missing_source != "NilClass"
|
|
14
22
|
nil
|
|
15
23
|
end
|
|
16
24
|
|
metadata
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: may_nil
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 0.1.1
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- Rue Meese
|
|
9
8
|
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 2016-11-10 00:00:00.000000000 Z
|
|
13
12
|
dependencies: []
|
|
14
13
|
description: Method chain to your heart's content
|
|
15
14
|
email: rupert.meese@lightmind.co.uk
|
|
@@ -21,26 +20,25 @@ files:
|
|
|
21
20
|
homepage: https://github.com/meesern/may_nil
|
|
22
21
|
licenses:
|
|
23
22
|
- MIT
|
|
23
|
+
metadata: {}
|
|
24
24
|
post_install_message:
|
|
25
25
|
rdoc_options: []
|
|
26
26
|
require_paths:
|
|
27
27
|
- lib
|
|
28
28
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
29
|
-
none: false
|
|
30
29
|
requirements:
|
|
31
|
-
- -
|
|
30
|
+
- - ">="
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
32
|
version: '0'
|
|
34
33
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
35
|
-
none: false
|
|
36
34
|
requirements:
|
|
37
|
-
- -
|
|
35
|
+
- - ">="
|
|
38
36
|
- !ruby/object:Gem::Version
|
|
39
37
|
version: '0'
|
|
40
38
|
requirements: []
|
|
41
39
|
rubyforge_project:
|
|
42
|
-
rubygems_version:
|
|
40
|
+
rubygems_version: 2.4.8
|
|
43
41
|
signing_key:
|
|
44
|
-
specification_version:
|
|
42
|
+
specification_version: 4
|
|
45
43
|
summary: May Nil
|
|
46
44
|
test_files: []
|