mug 0.0.5 → 0.0.6
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 +4 -4
- data/lib/mug/hashop.rb +15 -0
- data/test/test-hashop.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 096507698665e2384dc75549dc0c691729153514
|
4
|
+
data.tar.gz: cd4bb09ea9fadf13be4494abdb18b648854eac44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 099c99f1bbe1bf272c7d44cf7b32777183f93670c2d5e01854824ce54ab1c7f91e12a327dd217fe93f351214d719dd2439a3d74026f3a96d6d5aea40b5dcd94a
|
7
|
+
data.tar.gz: a5d64be2b7b44cba756eed062d11413a265c99d21b8ae4d15dcb3e46b057b1a111fa0b7809afd70c58503ff53430429e7f57a7ddda7af289febaaa3124f78af8
|
data/lib/mug/hashop.rb
CHANGED
@@ -16,6 +16,15 @@ class Hash
|
|
16
16
|
o.merge self
|
17
17
|
end
|
18
18
|
|
19
|
+
#
|
20
|
+
# Adds the contents of +other_hash+ to +hsh+.
|
21
|
+
# Entries with duplicate keys are overwritten with the
|
22
|
+
# values from +other_hash+
|
23
|
+
#
|
24
|
+
def + other_hash
|
25
|
+
merge other_hash
|
26
|
+
end
|
27
|
+
|
19
28
|
#
|
20
29
|
# Appends stuff to the hash.
|
21
30
|
#
|
@@ -24,6 +33,12 @@ class Hash
|
|
24
33
|
# If +o+ can be converted to a hash with #to_h, this is identical to calling #merge!
|
25
34
|
# Otherwise an ArgumentError is raised.
|
26
35
|
#
|
36
|
+
# Example:
|
37
|
+
# h = {}
|
38
|
+
# h << {:a=>0} # h = {:a=>0}
|
39
|
+
# h << {:b=>2,:c=>3} # h = {:a=>0,:b=>2,:c=>3}
|
40
|
+
# h << [:a,1] # h = {:a=>1,:b=>2,:c=>3}
|
41
|
+
#
|
27
42
|
def << o
|
28
43
|
if o.respond_to? :to_hash
|
29
44
|
merge! o.to_hash
|
data/test/test-hashop.rb
CHANGED
@@ -20,6 +20,18 @@ class Test_hashop < Test::Unit::TestCase
|
|
20
20
|
assert_equal( a|b, x )
|
21
21
|
end
|
22
22
|
end
|
23
|
+
def test_hash_plus
|
24
|
+
h = { :a => 1, :b => 2 }
|
25
|
+
[
|
26
|
+
[{}, h, h],
|
27
|
+
[{:c=>3}, h, {:a=>1, :b=>2, :c=>3}],
|
28
|
+
[{:a=>0, :b=>0}, h, h],
|
29
|
+
[{:a=>0, :c=>3}, h, {:a=>1, :b=>2, :c=>3}],
|
30
|
+
[h, {}, h],
|
31
|
+
].each do |a, b, x|
|
32
|
+
assert_equal( a+b, x )
|
33
|
+
end
|
34
|
+
end
|
23
35
|
def test_hash_poke
|
24
36
|
h = {}
|
25
37
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Kerwin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
== MUG: Matty's Ultimate Gem
|