webget_ruby_hash_more 1.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/LICENSE.txt +12 -0
- data/README.rdoc +31 -0
- data/lib/webget_ruby_hash_more.rb +46 -0
- data/test/webget_ruby_hash_more_test.rb +25 -0
- metadata +80 -0
- metadata.gz.sig +0 -0
data.tar.gz.sig
ADDED
Binary file
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
LICENSE
|
2
|
+
|
3
|
+
You may choose any of these licenses:
|
4
|
+
|
5
|
+
- CreativeCommons License, Non-commercial Share Alike
|
6
|
+
- LGPL, GNU Lesser General Public License
|
7
|
+
- MIT License
|
8
|
+
- Ruby License
|
9
|
+
|
10
|
+
THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
11
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
12
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
= WebGet Ruby Gem: HashMore
|
3
|
+
|
4
|
+
Author:: Joel Parker Henderson, joelparkerhenderson@gmail.com
|
5
|
+
Copyright:: Copyright (c) 2007-2010 Joel Parker Henderson
|
6
|
+
License:: CreativeCommons License, Non-commercial Share Alike
|
7
|
+
License:: LGPL, GNU Lesser General Public License
|
8
|
+
|
9
|
+
HashMore is a hash of hashes of hashes and so on recursively
|
10
|
+
|
11
|
+
Example
|
12
|
+
h = HashMore.new
|
13
|
+
h['foo']['bar']['baz'] = 'hello' # create the keys; set value to 'hello'
|
14
|
+
|
15
|
+
= Counting
|
16
|
+
|
17
|
+
Example
|
18
|
+
h = HashMore.new
|
19
|
+
h['foo']['bar']['baz'] += 5 # create the keys; set value to 5
|
20
|
+
|
21
|
+
Example of counting
|
22
|
+
for u in users
|
23
|
+
h[u.company][u.name]+=1
|
24
|
+
end
|
25
|
+
|
26
|
+
h['Acme'].keys
|
27
|
+
=> names of all the users at Acme
|
28
|
+
|
29
|
+
h['Acme']['John Doe']
|
30
|
+
=> how many users at Acme are named John Doe
|
31
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
=begin rdoc
|
2
|
+
|
3
|
+
= WebGet Ruby Gem: HashMore
|
4
|
+
|
5
|
+
Author:: Joel Parker Henderson, joelparkerhenderson@gmail.com
|
6
|
+
Copyright:: Copyright (c) 2007-2010 Joel Parker Henderson
|
7
|
+
License:: CreativeCommons License, Non-commercial Share Alike
|
8
|
+
License:: LGPL, GNU Lesser General Public License
|
9
|
+
|
10
|
+
HashMore is a hash of hashes of hashes and so on recursively
|
11
|
+
|
12
|
+
Example
|
13
|
+
h = HashMore.new
|
14
|
+
h['foo']['bar']['baz'] = 'hello' # create the keys; set value to 'hello'
|
15
|
+
|
16
|
+
= Counting
|
17
|
+
|
18
|
+
Example
|
19
|
+
h = HashMore.new
|
20
|
+
h['foo']['bar']['baz'] += 5 # create the keys; set value to 5
|
21
|
+
|
22
|
+
Example of counting
|
23
|
+
for u in users
|
24
|
+
h[u.company][u.name]+=1
|
25
|
+
end
|
26
|
+
|
27
|
+
h['Acme'].keys
|
28
|
+
=> names of all the users at Acme
|
29
|
+
|
30
|
+
h['Acme']['John Doe']
|
31
|
+
=> how many users at Acme are named John Doe
|
32
|
+
|
33
|
+
=end
|
34
|
+
|
35
|
+
|
36
|
+
class HashMore < Hash
|
37
|
+
|
38
|
+
def initialize
|
39
|
+
super{|h,k| h[k] = HashMore.new }
|
40
|
+
end
|
41
|
+
|
42
|
+
def +(x)
|
43
|
+
x
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'webget_ruby_hash_more'
|
3
|
+
|
4
|
+
class Testing < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_new
|
7
|
+
h = HashMore.new
|
8
|
+
assert_equal(h,{})
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_equal
|
12
|
+
h = HashMore.new
|
13
|
+
h[:a][:b][:c] = 'hello'
|
14
|
+
assert_equal(h[:a][:b][:c],'hello')
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_add
|
18
|
+
h = HashMore.new
|
19
|
+
h[:a][:b][:c] += 1
|
20
|
+
assert_equal(h[:a][:b][:c],1)
|
21
|
+
h[:a][:b][:c] += 1
|
22
|
+
assert_equal(h[:a][:b][:c],2)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: webget_ruby_hash_more
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.8
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- WebGet
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDvDCCAyWgAwIBAgIJAIlSqEkDQaZIMA0GCSqGSIb3DQEBBQUAMIGbMQswCQYD
|
14
|
+
VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZyYW5j
|
15
|
+
aXNjbzETMBEGA1UEChMKV2ViR2V0LmNvbTETMBEGA1UECxMKV2ViR2V0LmNvbTET
|
16
|
+
MBEGA1UEAxMKV2ViR2V0LmNvbTEgMB4GCSqGSIb3DQEJARYRd2ViZ2V0QHdlYmdl
|
17
|
+
dC5jb20wHhcNMDkwMjI2MTk0NDU4WhcNMTExMTIzMTk0NDU4WjCBmzELMAkGA1UE
|
18
|
+
BhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lz
|
19
|
+
Y28xEzARBgNVBAoTCldlYkdldC5jb20xEzARBgNVBAsTCldlYkdldC5jb20xEzAR
|
20
|
+
BgNVBAM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
|
+
email: webget@webget.com
|
41
|
+
executables: []
|
42
|
+
|
43
|
+
extensions: []
|
44
|
+
|
45
|
+
extra_rdoc_files: []
|
46
|
+
|
47
|
+
files:
|
48
|
+
- README.rdoc
|
49
|
+
- LICENSE.txt
|
50
|
+
- lib/webget_ruby_hash_more.rb
|
51
|
+
has_rdoc: true
|
52
|
+
homepage: http://webget.com/
|
53
|
+
licenses: []
|
54
|
+
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
version:
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: "0"
|
71
|
+
version:
|
72
|
+
requirements: []
|
73
|
+
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 1.3.5
|
76
|
+
signing_key:
|
77
|
+
specification_version: 3
|
78
|
+
summary: "WebGet Ruby Gem: HashMore class to create a recursive hash"
|
79
|
+
test_files:
|
80
|
+
- test/webget_ruby_hash_more_test.rb
|
metadata.gz.sig
ADDED
Binary file
|