nash 0.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 +37 -0
- data/lib/nash.rb +9 -0
- metadata +46 -0
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
## Introduction
|
2
|
+
|
3
|
+
Nash improves the error output if you get nil when expecting a hash.
|
4
|
+
|
5
|
+
Before: ```undefined method `[]' for nil:NilClass```
|
6
|
+
|
7
|
+
After: ```undefined method `[]' for nil:NilClass, with argument :foo```
|
8
|
+
|
9
|
+
**For example:**
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
hash = { :foo => { :bar => { :baz => {} }, :quux => nil } }
|
13
|
+
hash[:foo][:bar][:baz] # => {}
|
14
|
+
hash[:foo][:quux][:baz] # NoMethodError: undefined method `[]' for nil:NilClass, with argument :baz
|
15
|
+
```
|
16
|
+
|
17
|
+
So you know that `hash[:foo][:quux]` must be nil. Previously, you wouldn't know whether `hash[:foo]` or `hash[:foo][:quux]` was nil.
|
18
|
+
|
19
|
+
This is especially useful if you're feeling particularly contemptuous towards the law of demeter, or dealing with lots of hash nesting.
|
20
|
+
|
21
|
+
## Install
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
gem install nash
|
25
|
+
```
|
26
|
+
|
27
|
+
Then require it in an initializer:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
require 'nash'
|
31
|
+
```
|
32
|
+
|
33
|
+
## Contribution
|
34
|
+
|
35
|
+
Please feel free to contribute, either through pull requests or feature requests here on Github.
|
36
|
+
|
37
|
+
For news and the latest updates, follow me on Twitter ([@cpatuzzo](https://twitter.com/#!/cpatuzzo)).
|
data/lib/nash.rb
ADDED
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nash
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Christopher Patuzzo
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-04 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Improves the error output if you get nil when expecting a hash
|
15
|
+
email: chris.patuzzo@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- README.md
|
21
|
+
- lib/nash.rb
|
22
|
+
homepage: https://github.com/cpatuzzo/nash
|
23
|
+
licenses: []
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 1.8.15
|
43
|
+
signing_key:
|
44
|
+
specification_version: 3
|
45
|
+
summary: Improves the error output if you get nil when expecting a hash
|
46
|
+
test_files: []
|