neocrime-recursivehash 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.
Files changed (2) hide show
  1. data/lib/neocrime/recursivehash.rb +48 -0
  2. metadata +47 -0
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby2.0
2
+ # = Summary
3
+ #
4
+ # This module allows automatic recursive creation of hashes within hashes.
5
+ # It's merely an extension of core Hash and meant to be a drop-in replacement.
6
+ #
7
+ # Author:: Michael Henry (https://github.com/neoCrimeLabs)
8
+ # Copyright:: Copyright (c) 2015 Michael Henry
9
+ # License:: Mozilla Public License, v2.0
10
+ #
11
+ # = Examples
12
+ #
13
+ # == Regular Hash
14
+ #
15
+ # > regular = Hash.new
16
+ # => {}
17
+ # > regular['1']['2']['3'] = 'Testing'
18
+ # NoMethodError: undefined method `[]' for nil:NilClass
19
+ # from (irb):18
20
+ # from /usr/bin/irb:12:in `<main>'
21
+ # > regular
22
+ # => {}
23
+ #
24
+ # == Recursive Hash
25
+ #
26
+ # > > require 'neocrime/recursivehash'
27
+ # => true
28
+ # > recursive = NeoCrime::RecursiveHash.new
29
+ # => {}
30
+ # > recursive['1']['2']['3'] = 'Testing'
31
+ # => "Testing"
32
+ # > recursive
33
+ # => {"1"=>{"2"=>{"3"=>"Testing"}}}
34
+ #
35
+ #--
36
+ # This Source Code Form is subject to the terms of the Mozilla Public
37
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
38
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
39
+ # ++
40
+
41
+ module NeoCrime #:nodoc:
42
+ class RecursiveHash < ::Hash #:nodoc:
43
+ def initialize #:nodoc:
44
+ super { |hash, key| hash[key] = NeoCrime::RecursiveHash.new }
45
+ end
46
+ end
47
+ end
48
+
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: neocrime-recursivehash
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Michael Henry
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-04-21 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: This module allows automatic recursive creation of hashes within hashes.
15
+ It is merely an extension of core Hash and meant to be a drop-in replacement.
16
+ email: mhenry@neocri.me
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - lib/neocrime/recursivehash.rb
22
+ homepage: http://github.com/neoCrimeLabs/ruby_neocrime-recursivehash
23
+ licenses:
24
+ - MPLv2
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubyforge_project:
43
+ rubygems_version: 1.8.23
44
+ signing_key:
45
+ specification_version: 3
46
+ summary: This module allows automatic recursive creation of hashes within hashes.
47
+ test_files: []