hashslice 1.0.7 → 1.1.2
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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/{CHANGES → CHANGES.rdoc} +23 -0
- data/MANIFEST.rdoc +8 -0
- data/README.rdoc +49 -0
- data/Rakefile +28 -23
- data/certs/djberg96_pub.pem +26 -0
- data/hashslice.gemspec +17 -18
- data/lib/hashslice.rb +67 -60
- data/test/test_hashslice.rb +72 -73
- metadata +76 -50
- metadata.gz.sig +0 -0
- data/MANIFEST +0 -7
- data/README +0 -50
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2eccfcf2e5d663381ed72c26b20e46f692c3de8887a881461191691177963346
|
4
|
+
data.tar.gz: 8c407ae1ac1ff17626ea257dd22640b87240179df890f5e70237d53d7822642d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a54936b67bf3803052b6219ad1bcee5399ec25fe45b0208aa22c9fd6e4100b9e4b2b7205c72fe918cc1a3d3ba8780061cd03a5d9e6c524031a3628cf8a41707d
|
7
|
+
data.tar.gz: 676b38b2190fd0e153941ea89faf18c73ab7081bc3fa642fd5bd087d50367575c44500ba30ed1b35485fd94681443236b0a130274e0312343102ebda65ac16f5
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
Binary file
|
data/{CHANGES → CHANGES.rdoc}
RENAMED
@@ -1,3 +1,26 @@
|
|
1
|
+
== 1.1.2 - 14-Jul-2020
|
2
|
+
* Now silences the redefinition warning.
|
3
|
+
* Fix the license name in the gemspec (missing hyphen).
|
4
|
+
* Add an explicit .rdoc extension to the README, MANIFEST and CHANGES files.
|
5
|
+
* Added a loose dependency (version 3+) to the test-unit development dependency.
|
6
|
+
|
7
|
+
== 1.1.1 - 5-Apr-2018
|
8
|
+
* Fixed deprecation warnings for Ruby 2.4 and later.
|
9
|
+
* The VERSION_HASHSLICE constant is now frozen.
|
10
|
+
* Updated the cert.
|
11
|
+
|
12
|
+
== 1.1.0 - 7-Dec-2015
|
13
|
+
* This gem is now signed.
|
14
|
+
* Updates to the gemspec and Rakefile.
|
15
|
+
|
16
|
+
== 1.0.9 - 19-Sep-2011
|
17
|
+
* Cosmetic updates to silence Ruby 1.9.x warnings.
|
18
|
+
|
19
|
+
== 1.0.8 - 31-Aug-2011
|
20
|
+
* Removed an old install task, updated the clean task and set a
|
21
|
+
default task in the Rakefile.
|
22
|
+
* Minor updates to the gemspec.
|
23
|
+
|
1
24
|
== 1.0.7 - 27-Sep-2009
|
2
25
|
* Fixed a packaging bug.
|
3
26
|
* Minor updates to the gemspec.
|
data/MANIFEST.rdoc
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
= Description
|
2
|
+
Slicing for Ruby hashes.
|
3
|
+
|
4
|
+
= Installation
|
5
|
+
gem install hashslice
|
6
|
+
|
7
|
+
= Synopsis
|
8
|
+
require 'hashslice'
|
9
|
+
|
10
|
+
hash = {'a' => 1, 'b' => 2, 'c' => 3}
|
11
|
+
|
12
|
+
# Slice reference
|
13
|
+
hash['a', 'b'] # -> [1, 2]
|
14
|
+
hash['a'] # -> 1
|
15
|
+
|
16
|
+
# Slice assignment
|
17
|
+
hash['a', 'b'] = 7, 8
|
18
|
+
|
19
|
+
hash # -> {'a' => 7, 'b' => 8, 'c' => 3}
|
20
|
+
|
21
|
+
# Sub hash
|
22
|
+
hash.hash_of('a', 'b') # -> {'a' => 1, 'b' => 2}
|
23
|
+
|
24
|
+
= Overview
|
25
|
+
This library modifies the Hash#[] and Hash#[]= methods so that they can
|
26
|
+
handle list reference or assignment. It also adds the Hash#hash_of method
|
27
|
+
that returns a hash slice.
|
28
|
+
|
29
|
+
== Hash#[*keys]
|
30
|
+
If more than one key is provided then an array is returned. Single
|
31
|
+
keys work as before, i.e. they return a single value.
|
32
|
+
|
33
|
+
== Hash#[*keys]=(*values)
|
34
|
+
The values on the right are assigned to the keys on left on a one for one
|
35
|
+
If there are more values than keys, the extra values are dropped.
|
36
|
+
|
37
|
+
= Copyright
|
38
|
+
Copyright (c) 2001-2020, The FaerieMUD Consortium and Daniel J. Berger.
|
39
|
+
All rights reserved.
|
40
|
+
|
41
|
+
= License
|
42
|
+
This module is free software. You may use, modify, and/or redistribute this
|
43
|
+
software under the terms of the Artistic License 2.0
|
44
|
+
|
45
|
+
http://www.perlfoundation.org/artistic_license_2_0
|
46
|
+
|
47
|
+
= Authors
|
48
|
+
* Michael Granger (original author)
|
49
|
+
* Daniel Berger (current maintainer)
|
data/Rakefile
CHANGED
@@ -1,23 +1,28 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/clean'
|
3
|
-
require 'rake/testtask'
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'rake/testtask'
|
4
|
+
|
5
|
+
CLEAN.include("**/*.gem", "**/*.rbc")
|
6
|
+
|
7
|
+
namespace :gem do
|
8
|
+
desc 'Build the hashslice gem'
|
9
|
+
task :create => [:clean] do
|
10
|
+
require 'rubygems/package'
|
11
|
+
spec = eval(IO.read('hashslice.gemspec'))
|
12
|
+
spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
|
13
|
+
Gem::Package.build(spec)
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Install the hashslice library as a gem"
|
17
|
+
task :install => [:create] do
|
18
|
+
file = Dir["*.gem"].first
|
19
|
+
sh "gem install -l #{file}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
Rake::TestTask.new do |t|
|
24
|
+
t.warning = true
|
25
|
+
t.verbose = true
|
26
|
+
end
|
27
|
+
|
28
|
+
task :default => :test
|
@@ -0,0 +1,26 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MREwDwYDVQQDDAhkamJl
|
3
|
+
cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
|
4
|
+
MB4XDTE4MDMxODE1MjIwN1oXDTI4MDMxNTE1MjIwN1owPzERMA8GA1UEAwwIZGpi
|
5
|
+
ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
|
6
|
+
bTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALgfaroVM6CI06cxr0/h
|
7
|
+
A+j+pc8fgpRgBVmHFaFunq28GPC3IvW7Nvc3Y8SnAW7pP1EQIbhlwRIaQzJ93/yj
|
8
|
+
u95KpkP7tA9erypnV7dpzBkzNlX14ACaFD/6pHoXoe2ltBxk3CCyyzx70mTqJpph
|
9
|
+
75IB03ni9a8yqn8pmse+s83bFJOAqddSj009sGPcQO+QOWiNxqYv1n5EHcvj2ebO
|
10
|
+
6hN7YTmhx7aSia4qL/quc4DlIaGMWoAhvML7u1fmo53CYxkKskfN8MOecq2vfEmL
|
11
|
+
iLu+SsVVEAufMDDFMXMJlvDsviolUSGMSNRTujkyCcJoXKYYxZSNtIiyd9etI0X3
|
12
|
+
ctu0uhrFyrMZXCedutvXNjUolD5r9KGBFSWH1R9u2I3n3SAyFF2yzv/7idQHLJJq
|
13
|
+
74BMnx0FIq6fCpu5slAipvxZ3ZkZpEXZFr3cIBtO1gFvQWW7E/Y3ijliWJS1GQFq
|
14
|
+
058qERadHGu1yu1dojmFRo6W2KZvY9al2yIlbkpDrD5MYQIDAQABo3cwdTAJBgNV
|
15
|
+
HRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUFZsMapgzJimzsbaBG2Tm8j5e
|
16
|
+
AzgwHQYDVR0RBBYwFIESZGpiZXJnOTZAZ21haWwuY29tMB0GA1UdEgQWMBSBEmRq
|
17
|
+
YmVyZzk2QGdtYWlsLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEAW2tnYixXQtKxgGXq
|
18
|
+
/3iSWG2bLwvxS4go3srO+aRXZHrFUMlJ5W0mCxl03aazxxKTsVVpZD8QZxvK91OQ
|
19
|
+
h9zr9JBYqCLcCVbr8SkmYCi/laxIZxsNE5YI8cC8vvlLI7AMgSfPSnn/Epq1GjGY
|
20
|
+
6L1iRcEDtanGCIvjqlCXO9+BmsnCfEVehqZkQHeYczA03tpOWb6pon2wzvMKSsKH
|
21
|
+
ks0ApVdstSLz1kzzAqem/uHdG9FyXdbTAwH1G4ZPv69sQAFAOCgAqYmdnzedsQtE
|
22
|
+
1LQfaQrx0twO+CZJPcRLEESjq8ScQxWRRkfuh2VeR7cEU7L7KqT10mtUwrvw7APf
|
23
|
+
DYoeCY9KyjIBjQXfbj2ke5u1hZj94Fsq9FfbEQg8ygCgwThnmkTrrKEiMSs3alYR
|
24
|
+
ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
|
25
|
+
WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
|
26
|
+
-----END CERTIFICATE-----
|
data/hashslice.gemspec
CHANGED
@@ -1,25 +1,24 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
4
|
+
gem.name = 'hashslice'
|
5
|
+
gem.version = '1.1.2'
|
6
|
+
gem.authors = ['Daniel J. Berger', 'Michael Granger']
|
7
|
+
gem.license = 'Artistic-2.0'
|
8
|
+
gem.email = 'djberg96@gmail.com'
|
9
|
+
gem.homepage = 'http://github.com/djberg96/hashslice'
|
10
|
+
gem.summary = "Adds hash slicing to Ruby's Hash class"
|
11
|
+
gem.test_file = 'test/test_hashslice.rb'
|
12
|
+
gem.files = Dir['**/*'].reject{ |f| f.include?('git') }
|
13
|
+
gem.cert_chain = Dir['certs/*']
|
14
14
|
|
15
|
-
|
16
|
-
gem.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
|
15
|
+
gem.extra_rdoc_files = ['README.rdoc', 'CHANGES.rdoc', 'MANIFEST.rdoc']
|
17
16
|
|
18
|
-
|
17
|
+
gem.add_development_dependency('test-unit', '~> 3')
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
gem.description = <<-EOF
|
20
|
+
The hashslice library adds builtin hash slicing to Ruby's Hash class.
|
21
|
+
This lets you reference, or assign to, multiple hash keys simultaneously
|
22
|
+
via the Hash#[] and Hash#[]= methods, respectively.
|
23
|
+
EOF
|
25
24
|
end
|
data/lib/hashslice.rb
CHANGED
@@ -1,65 +1,72 @@
|
|
1
1
|
class Hash
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
# The version of the hashslice library
|
6
|
-
VERSION_HASHSLICE = '1.0.7'
|
2
|
+
alias href []
|
3
|
+
alias hset []=
|
7
4
|
|
8
|
-
|
9
|
-
|
10
|
-
#
|
11
|
-
# Examples:
|
12
|
-
#
|
13
|
-
# hash = {'a' => 1, 'b' => 2, 'c' => 3}
|
14
|
-
# hash['a'] -> 1
|
15
|
-
# hash['a', 'c'] -> [1, 3]
|
16
|
-
#
|
17
|
-
def [](*args)
|
18
|
-
if args.length == 1
|
19
|
-
href(args[0])
|
20
|
-
else
|
21
|
-
args.map{ |k| href(k) }
|
22
|
-
end
|
23
|
-
end
|
5
|
+
# The version of the hashslice library
|
6
|
+
VERSION_HASHSLICE = '1.1.2'.freeze
|
24
7
|
|
25
|
-
|
8
|
+
# Retrieve a hash slice. If a single key is provided, returns a single
|
9
|
+
# value. If multiple keys are provided, an array of values is returned.
|
10
|
+
#
|
11
|
+
# Examples:
|
12
|
+
#
|
13
|
+
# hash = {'a' => 1, 'b' => 2, 'c' => 3}
|
14
|
+
# hash['a'] -> 1
|
15
|
+
# hash['a', 'c'] -> [1, 3]
|
16
|
+
#
|
17
|
+
def [](*args)
|
18
|
+
if args.length == 1
|
19
|
+
href(args[0])
|
20
|
+
else
|
21
|
+
args.map{ |k| href(k) }
|
22
|
+
end
|
23
|
+
end
|
26
24
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
25
|
+
# Temporarily silence redefinition warning.
|
26
|
+
begin
|
27
|
+
old_verbose = $VERBOSE
|
28
|
+
$VERBOSE = false
|
29
|
+
alias slice []
|
30
|
+
ensure
|
31
|
+
$VERBOSE = old_verbose
|
32
|
+
end
|
33
|
+
|
34
|
+
# Hash slice assignment. You can assign a list of values to a list of keys
|
35
|
+
# in a single operation on a one for one basis.
|
36
|
+
#
|
37
|
+
# If the number of keys exceeds the number of values, the remaining keys
|
38
|
+
# are assigned a value of nil.
|
39
|
+
#
|
40
|
+
# If the number of values exceeds the number of keys, the extra values are
|
41
|
+
# dropped.
|
42
|
+
#
|
43
|
+
# Examples:
|
44
|
+
#
|
45
|
+
# hash['a'] = 1, 2 -> {a => [1, 2]}
|
46
|
+
# hash['a', 'b'] = 3, 4 -> {a => 3, b => 4}
|
47
|
+
# hash['a', 'b'] = 5 -> {a => 5, b => nil}
|
48
|
+
# hash['a', 'b'] = 3, 4, 5 -> {a => 3, b => 4}
|
49
|
+
#
|
50
|
+
def []=(*args)
|
51
|
+
if args.length <= 2
|
52
|
+
hset(*args)
|
53
|
+
else
|
54
|
+
values = args.pop # Last arg is the value. The rest are keys.
|
55
|
+
values = [values] unless values.is_a?(Array)
|
56
|
+
args.each_index{ |i| hset(args[i], values[i]) }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Returns a sub-hash of the current hash.
|
61
|
+
#
|
62
|
+
# Example:
|
63
|
+
#
|
64
|
+
# hash = {'a' => 1, 'b' => 2, 'c' => 3}
|
65
|
+
# hash.hash_of('a', 'b') -> {'a' => 1, 'b' => 2}
|
66
|
+
#
|
67
|
+
def hash_of(*args)
|
68
|
+
temp = {}
|
69
|
+
args.map{ |k| temp[k] = href(k) }
|
70
|
+
temp
|
71
|
+
end
|
65
72
|
end
|
data/test/test_hashslice.rb
CHANGED
@@ -5,91 +5,90 @@
|
|
5
5
|
# via the 'rake test' task.
|
6
6
|
#######################################################################
|
7
7
|
require 'rubygems'
|
8
|
-
gem 'test-unit'
|
9
|
-
|
10
8
|
require 'hashslice'
|
11
|
-
require 'test
|
9
|
+
require 'test-unit'
|
12
10
|
|
13
11
|
class TC_Hashslice < Test::Unit::TestCase
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
def setup
|
13
|
+
@hash = {'a' => 1, 'b' => 2}
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_version
|
17
|
+
assert_equal('1.1.2', Hash::VERSION_HASHSLICE)
|
18
|
+
assert_true(Hash::VERSION_HASHSLICE.frozen?)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_get_slice_instance_method_basic
|
22
|
+
assert_respond_to(@hash, :[])
|
23
|
+
assert_nothing_raised{ @hash['a'] }
|
24
|
+
assert_nothing_raised{ @hash['a', 'b'] }
|
25
|
+
assert_kind_of(Integer, @hash['a'])
|
26
|
+
assert_kind_of(Array, @hash['a', 'b'])
|
27
|
+
end
|
17
28
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
assert_nothing_raised{ @hash['a'] }
|
25
|
-
assert_nothing_raised{ @hash['a', 'b'] }
|
26
|
-
assert_kind_of(Integer, @hash['a'])
|
27
|
-
assert_kind_of(Array, @hash['a', 'b'])
|
28
|
-
end
|
29
|
+
def test_get_slice_instance_method
|
30
|
+
assert_equal(1, @hash['a'])
|
31
|
+
assert_equal([1, 2], @hash['a', 'b'])
|
32
|
+
assert_equal([1, 2, nil], @hash['a', 'b', 'c'])
|
33
|
+
assert_nil(@hash['bogus'])
|
34
|
+
end
|
29
35
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
assert_nil(@hash['bogus'])
|
35
|
-
end
|
36
|
+
def test_get_slice_duplicate_keys
|
37
|
+
assert_equal([1, 1], @hash['a', 'a'])
|
38
|
+
assert_equal([1, 2, 1, 2], @hash['a', 'b', 'a', 'b'])
|
39
|
+
end
|
36
40
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
+
def test_set_slice_instance_method_basic
|
42
|
+
assert_respond_to(@hash, :[]=)
|
43
|
+
assert_nothing_raised{ @hash['a'] = 3 }
|
44
|
+
assert_nothing_raised{ @hash['a', 'b'] = 3 }
|
45
|
+
assert_nothing_raised{ @hash['a', 'b'] = 3, 4 }
|
46
|
+
assert_kind_of(Integer, @hash['a'] = 3)
|
47
|
+
assert_kind_of(Integer, @hash['a', 'b'] = 3)
|
48
|
+
assert_kind_of(Integer, @hash['a', 'b'] = 3, 4)
|
49
|
+
end
|
41
50
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
assert_kind_of(Fixnum, @hash['a', 'b'] = 3)
|
49
|
-
assert_kind_of(Fixnum, @hash['a', 'b'] = 3, 4)
|
50
|
-
end
|
51
|
+
# hash[key] = value
|
52
|
+
def test_set_slice_instance_method_single_key_and_value
|
53
|
+
assert_nothing_raised{ @hash['a'] = 3 }
|
54
|
+
assert_nothing_raised{ @hash['b'] = [1, 2] }
|
55
|
+
assert_equal({'a' => 3, 'b' => [1, 2]}, @hash)
|
56
|
+
end
|
51
57
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
58
|
+
# hash[key1, key2] = value
|
59
|
+
def test_set_slice_instance_method_multiple_keys_single_value
|
60
|
+
assert_nothing_raised{ @hash['a', 'b'] = 3 }
|
61
|
+
assert_equal({'a' => 3, 'b' => nil}, @hash)
|
62
|
+
end
|
58
63
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
+
# hash[key1, key2] = value1, value2
|
65
|
+
def test_set_slice_instance_method_multiple_keys_multiple_values
|
66
|
+
assert_nothing_raised{ @hash['a', 'b'] = 3, 4 }
|
67
|
+
assert_equal({'a' => 3, 'b' => 4}, @hash)
|
68
|
+
end
|
64
69
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
+
# hash[key] = value1, value2
|
71
|
+
def test_set_slice_instance_method_single_key_multiple_values
|
72
|
+
assert_nothing_raised{ @hash['a'] = 3, 4 }
|
73
|
+
assert_equal({'a' => [3, 4], 'b' => 2}, @hash)
|
74
|
+
end
|
70
75
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
+
# hash[key1, key2] = value1, value2, value3
|
77
|
+
def test_set_slice_instance_method_multiple_keys_odd_values
|
78
|
+
assert_nothing_raised{ @hash['a', 'b'] = 3, 4, 5 }
|
79
|
+
assert_equal({'a' => 3, 'b' => 4}, @hash)
|
80
|
+
end
|
76
81
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
assert_equal({'a' => 3, 'b' => 4}, @hash)
|
81
|
-
end
|
82
|
+
def test_slice_alias
|
83
|
+
assert_true(Hash.instance_method(:slice) == Hash.instance_method(:[]))
|
84
|
+
end
|
82
85
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
def test_hash_of
|
88
|
-
assert_respond_to(@hash, :hash_of)
|
89
|
-
assert_equal({'a' => 1, 'b' => 2}, @hash.hash_of('a', 'b'))
|
90
|
-
end
|
86
|
+
def test_hash_of
|
87
|
+
assert_respond_to(@hash, :hash_of)
|
88
|
+
assert_equal({'a' => 1, 'b' => 2}, @hash.hash_of('a', 'b'))
|
89
|
+
end
|
91
90
|
|
92
|
-
|
93
|
-
|
94
|
-
|
91
|
+
def teardown
|
92
|
+
@hash = nil
|
93
|
+
end
|
95
94
|
end
|
metadata
CHANGED
@@ -1,73 +1,99 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: hashslice
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Daniel J. Berger
|
8
8
|
- Michael Granger
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
|
-
cert_chain:
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
cert_chain:
|
12
|
+
- |
|
13
|
+
-----BEGIN CERTIFICATE-----
|
14
|
+
MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MREwDwYDVQQDDAhkamJl
|
15
|
+
cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
|
16
|
+
MB4XDTE4MDMxODE1MjIwN1oXDTI4MDMxNTE1MjIwN1owPzERMA8GA1UEAwwIZGpi
|
17
|
+
ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
|
18
|
+
bTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALgfaroVM6CI06cxr0/h
|
19
|
+
A+j+pc8fgpRgBVmHFaFunq28GPC3IvW7Nvc3Y8SnAW7pP1EQIbhlwRIaQzJ93/yj
|
20
|
+
u95KpkP7tA9erypnV7dpzBkzNlX14ACaFD/6pHoXoe2ltBxk3CCyyzx70mTqJpph
|
21
|
+
75IB03ni9a8yqn8pmse+s83bFJOAqddSj009sGPcQO+QOWiNxqYv1n5EHcvj2ebO
|
22
|
+
6hN7YTmhx7aSia4qL/quc4DlIaGMWoAhvML7u1fmo53CYxkKskfN8MOecq2vfEmL
|
23
|
+
iLu+SsVVEAufMDDFMXMJlvDsviolUSGMSNRTujkyCcJoXKYYxZSNtIiyd9etI0X3
|
24
|
+
ctu0uhrFyrMZXCedutvXNjUolD5r9KGBFSWH1R9u2I3n3SAyFF2yzv/7idQHLJJq
|
25
|
+
74BMnx0FIq6fCpu5slAipvxZ3ZkZpEXZFr3cIBtO1gFvQWW7E/Y3ijliWJS1GQFq
|
26
|
+
058qERadHGu1yu1dojmFRo6W2KZvY9al2yIlbkpDrD5MYQIDAQABo3cwdTAJBgNV
|
27
|
+
HRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUFZsMapgzJimzsbaBG2Tm8j5e
|
28
|
+
AzgwHQYDVR0RBBYwFIESZGpiZXJnOTZAZ21haWwuY29tMB0GA1UdEgQWMBSBEmRq
|
29
|
+
YmVyZzk2QGdtYWlsLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEAW2tnYixXQtKxgGXq
|
30
|
+
/3iSWG2bLwvxS4go3srO+aRXZHrFUMlJ5W0mCxl03aazxxKTsVVpZD8QZxvK91OQ
|
31
|
+
h9zr9JBYqCLcCVbr8SkmYCi/laxIZxsNE5YI8cC8vvlLI7AMgSfPSnn/Epq1GjGY
|
32
|
+
6L1iRcEDtanGCIvjqlCXO9+BmsnCfEVehqZkQHeYczA03tpOWb6pon2wzvMKSsKH
|
33
|
+
ks0ApVdstSLz1kzzAqem/uHdG9FyXdbTAwH1G4ZPv69sQAFAOCgAqYmdnzedsQtE
|
34
|
+
1LQfaQrx0twO+CZJPcRLEESjq8ScQxWRRkfuh2VeR7cEU7L7KqT10mtUwrvw7APf
|
35
|
+
DYoeCY9KyjIBjQXfbj2ke5u1hZj94Fsq9FfbEQg8ygCgwThnmkTrrKEiMSs3alYR
|
36
|
+
ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
|
37
|
+
WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
|
38
|
+
-----END CERTIFICATE-----
|
39
|
+
date: 2020-07-14 00:00:00.000000000 Z
|
40
|
+
dependencies:
|
41
|
+
- !ruby/object:Gem::Dependency
|
17
42
|
name: test-unit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3'
|
18
48
|
type: :development
|
19
|
-
|
20
|
-
version_requirements: !ruby/object:Gem::Requirement
|
21
|
-
requirements:
|
22
|
-
- - "
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version:
|
25
|
-
|
26
|
-
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3'
|
55
|
+
description: |2
|
56
|
+
The hashslice library adds builtin hash slicing to Ruby's Hash class.
|
57
|
+
This lets you reference, or assign to, multiple hash keys simultaneously
|
58
|
+
via the Hash#[] and Hash#[]= methods, respectively.
|
27
59
|
email: djberg96@gmail.com
|
28
60
|
executables: []
|
29
|
-
|
30
61
|
extensions: []
|
31
|
-
|
32
|
-
|
33
|
-
-
|
34
|
-
-
|
35
|
-
|
36
|
-
|
37
|
-
-
|
62
|
+
extra_rdoc_files:
|
63
|
+
- README.rdoc
|
64
|
+
- CHANGES.rdoc
|
65
|
+
- MANIFEST.rdoc
|
66
|
+
files:
|
67
|
+
- CHANGES.rdoc
|
68
|
+
- MANIFEST.rdoc
|
69
|
+
- README.rdoc
|
70
|
+
- Rakefile
|
71
|
+
- certs/djberg96_pub.pem
|
38
72
|
- hashslice.gemspec
|
39
73
|
- lib/hashslice.rb
|
40
|
-
- MANIFEST
|
41
|
-
- Rakefile
|
42
|
-
- README
|
43
74
|
- test/test_hashslice.rb
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
75
|
+
homepage: http://github.com/djberg96/hashslice
|
76
|
+
licenses:
|
77
|
+
- Artistic-2.0
|
78
|
+
metadata: {}
|
48
79
|
post_install_message:
|
49
80
|
rdoc_options: []
|
50
|
-
|
51
|
-
require_paths:
|
81
|
+
require_paths:
|
52
82
|
- lib
|
53
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
-
requirements:
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
55
85
|
- - ">="
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version:
|
58
|
-
|
59
|
-
|
60
|
-
requirements:
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
61
90
|
- - ">="
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version:
|
64
|
-
version:
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
65
93
|
requirements: []
|
66
|
-
|
67
|
-
rubyforge_project: shards
|
68
|
-
rubygems_version: 1.3.5
|
94
|
+
rubygems_version: 3.0.3
|
69
95
|
signing_key:
|
70
|
-
specification_version:
|
96
|
+
specification_version: 4
|
71
97
|
summary: Adds hash slicing to Ruby's Hash class
|
72
|
-
test_files:
|
98
|
+
test_files:
|
73
99
|
- test/test_hashslice.rb
|
metadata.gz.sig
ADDED
Binary file
|
data/MANIFEST
DELETED
data/README
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
= Description
|
2
|
-
Slicing for Ruby hashes.
|
3
|
-
|
4
|
-
= Installation
|
5
|
-
rake test (optional)
|
6
|
-
rake install
|
7
|
-
|
8
|
-
= Synopsis
|
9
|
-
require 'hashslice'
|
10
|
-
|
11
|
-
hash = {'a' => 1, 'b' => 2, 'c' => 3}
|
12
|
-
|
13
|
-
# Slice reference
|
14
|
-
hash['a', 'b'] # -> [1, 2]
|
15
|
-
hash['a'] # -> 1
|
16
|
-
|
17
|
-
# Slice assignment
|
18
|
-
hash['a', 'b'] = 7, 8
|
19
|
-
|
20
|
-
hash # -> {'a' => 7, 'b' => 8, 'c' => 3}
|
21
|
-
|
22
|
-
# Sub hash
|
23
|
-
hash.hash_of('a', 'b') # -> {'a' => 1, 'b' => 2}
|
24
|
-
|
25
|
-
= Overview
|
26
|
-
This library modifies the Hash#[] and Hash#[]= methods so that they can
|
27
|
-
handle list reference or assignment. It also adds the Hash#hash_of method
|
28
|
-
that returns a hash slice.
|
29
|
-
|
30
|
-
== Hash#[*keys]
|
31
|
-
If more than one key is provided then an array is returned. Single
|
32
|
-
keys work as before, i.e. they return a single value.
|
33
|
-
|
34
|
-
== Hash#[*keys]=(*values)
|
35
|
-
The values on the right are assigned to the keys on left on a one for one
|
36
|
-
If there are more values than keys, the extra values are dropped.
|
37
|
-
|
38
|
-
= Copyright
|
39
|
-
Copyright (c) 2001-2009, The FaerieMUD Consortium and Daniel J. Berger.
|
40
|
-
All rights reserved.
|
41
|
-
|
42
|
-
= License
|
43
|
-
This module is free software. You may use, modify, and/or redistribute this
|
44
|
-
software under the terms of the Artistic License 2.0
|
45
|
-
|
46
|
-
http://www.perlfoundation.org/artistic_license_2_0
|
47
|
-
|
48
|
-
= Authors
|
49
|
-
Michael Granger (original author)
|
50
|
-
Daniel Berger (current maintainer)
|