hashslice 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,6 @@
1
+ == 1.0.9 - 19-Sep-2011
2
+ * Cosmetic updates to silence Ruby 1.9.x warnings.
3
+
1
4
  == 1.0.8 - 31-Aug-2011
2
5
  * Removed an old install task, updated the clean task and set a
3
6
  default task in the Rakefile.
data/hashslice.gemspec CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'hashslice'
5
- gem.version = '1.0.8'
5
+ gem.version = '1.0.9'
6
6
  gem.authors = ['Daniel J. Berger', 'Michael Granger']
7
7
  gem.license = 'Artistic 2.0'
8
8
  gem.email = 'djberg96@gmail.com'
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
14
14
  gem.rubyforge_project = 'shards'
15
15
  gem.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
16
16
 
17
- gem.add_development_dependency('test-unit', '>= 2.1.0')
17
+ gem.add_development_dependency('test-unit')
18
18
 
19
19
  gem.description = <<-EOF
20
20
  The hashslice library adds builtin hash slicing to Ruby's Hash class.
data/lib/hashslice.rb CHANGED
@@ -3,7 +3,7 @@ class Hash
3
3
  alias hset []=
4
4
 
5
5
  # The version of the hashslice library
6
- VERSION_HASHSLICE = '1.0.8'
6
+ VERSION_HASHSLICE = '1.0.9'
7
7
 
8
8
  # Retrieve a hash slice. If a single key is provided, returns a single
9
9
  # value. If multiple keys are provided, an array of values is returned.
@@ -46,9 +46,9 @@ class Hash
46
46
  else
47
47
  values = args.pop # Last arg is the value. The rest are keys.
48
48
  values = [values] unless values.is_a?(Array)
49
- args.each_index{ |i| hset(args[i], values[i]) }
50
- end
51
- end
49
+ args.each_index{ |i| hset(args[i], values[i]) }
50
+ end
51
+ end
52
52
 
53
53
  # Returns a sub-hash of the current hash.
54
54
  #
@@ -11,85 +11,85 @@ require 'hashslice'
11
11
  require 'test/unit'
12
12
 
13
13
  class TC_Hashslice < Test::Unit::TestCase
14
- def setup
15
- @hash = {'a' => 1, 'b' => 2}
16
- end
14
+ def setup
15
+ @hash = {'a' => 1, 'b' => 2}
16
+ end
17
17
 
18
- def test_version
19
- assert_equal('1.0.8', Hash::VERSION_HASHSLICE)
20
- end
18
+ def test_version
19
+ assert_equal('1.0.9', Hash::VERSION_HASHSLICE)
20
+ end
21
21
 
22
- def test_get_slice_instance_method_basic
23
- assert_respond_to(@hash, :[])
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
22
+ def test_get_slice_instance_method_basic
23
+ assert_respond_to(@hash, :[])
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
29
 
30
- def test_get_slice_instance_method
31
- assert_equal(1, @hash['a'])
32
- assert_equal([1, 2], @hash['a', 'b'])
33
- assert_equal([1, 2, nil], @hash['a', 'b', 'c'])
34
- assert_nil(@hash['bogus'])
35
- end
30
+ def test_get_slice_instance_method
31
+ assert_equal(1, @hash['a'])
32
+ assert_equal([1, 2], @hash['a', 'b'])
33
+ assert_equal([1, 2, nil], @hash['a', 'b', 'c'])
34
+ assert_nil(@hash['bogus'])
35
+ end
36
36
 
37
- def test_get_slice_duplicate_keys
38
- assert_equal([1, 1], @hash['a', 'a'])
39
- assert_equal([1, 2, 1, 2], @hash['a', 'b', 'a', 'b'])
40
- end
37
+ def test_get_slice_duplicate_keys
38
+ assert_equal([1, 1], @hash['a', 'a'])
39
+ assert_equal([1, 2, 1, 2], @hash['a', 'b', 'a', 'b'])
40
+ end
41
41
 
42
- def test_set_slice_instance_method_basic
43
- assert_respond_to(@hash, :[]=)
44
- assert_nothing_raised{ @hash['a'] = 3 }
45
- assert_nothing_raised{ @hash['a', 'b'] = 3 }
46
- assert_nothing_raised{ @hash['a', 'b'] = 3, 4 }
47
- assert_kind_of(Fixnum, @hash['a'] = 3)
48
- assert_kind_of(Fixnum, @hash['a', 'b'] = 3)
49
- assert_kind_of(Fixnum, @hash['a', 'b'] = 3, 4)
50
- end
42
+ def test_set_slice_instance_method_basic
43
+ assert_respond_to(@hash, :[]=)
44
+ assert_nothing_raised{ @hash['a'] = 3 }
45
+ assert_nothing_raised{ @hash['a', 'b'] = 3 }
46
+ assert_nothing_raised{ @hash['a', 'b'] = 3, 4 }
47
+ assert_kind_of(Fixnum, @hash['a'] = 3)
48
+ assert_kind_of(Fixnum, @hash['a', 'b'] = 3)
49
+ assert_kind_of(Fixnum, @hash['a', 'b'] = 3, 4)
50
+ end
51
51
 
52
- # hash[key] = value
53
- def test_set_slice_instance_method_single_key_and_value
54
- assert_nothing_raised{ @hash['a'] = 3 }
55
- assert_nothing_raised{ @hash['b'] = [1, 2] }
56
- assert_equal({'a' => 3, 'b' => [1, 2]}, @hash)
57
- end
52
+ # hash[key] = value
53
+ def test_set_slice_instance_method_single_key_and_value
54
+ assert_nothing_raised{ @hash['a'] = 3 }
55
+ assert_nothing_raised{ @hash['b'] = [1, 2] }
56
+ assert_equal({'a' => 3, 'b' => [1, 2]}, @hash)
57
+ end
58
58
 
59
- # hash[key1, key2] = value
60
- def test_set_slice_instance_method_multiple_keys_single_value
61
- assert_nothing_raised{ @hash['a', 'b'] = 3 }
62
- assert_equal({'a' => 3, 'b' => nil}, @hash)
63
- end
59
+ # hash[key1, key2] = value
60
+ def test_set_slice_instance_method_multiple_keys_single_value
61
+ assert_nothing_raised{ @hash['a', 'b'] = 3 }
62
+ assert_equal({'a' => 3, 'b' => nil}, @hash)
63
+ end
64
64
 
65
- # hash[key1, key2] = value1, value2
66
- def test_set_slice_instance_method_multiple_keys_multiple_values
67
- assert_nothing_raised{ @hash['a', 'b'] = 3, 4 }
68
- assert_equal({'a' => 3, 'b' => 4}, @hash)
69
- end
65
+ # hash[key1, key2] = value1, value2
66
+ def test_set_slice_instance_method_multiple_keys_multiple_values
67
+ assert_nothing_raised{ @hash['a', 'b'] = 3, 4 }
68
+ assert_equal({'a' => 3, 'b' => 4}, @hash)
69
+ end
70
70
 
71
- # hash[key] = value1, value2
72
- def test_set_slice_instance_method_single_key_multiple_values
73
- assert_nothing_raised{ @hash['a'] = 3, 4 }
74
- assert_equal({'a' => [3, 4], 'b' => 2}, @hash)
75
- end
71
+ # hash[key] = value1, value2
72
+ def test_set_slice_instance_method_single_key_multiple_values
73
+ assert_nothing_raised{ @hash['a'] = 3, 4 }
74
+ assert_equal({'a' => [3, 4], 'b' => 2}, @hash)
75
+ end
76
76
 
77
- # hash[key1, key2] = value1, value2, value3
78
- def test_set_slice_instance_method_multiple_keys_odd_values
79
- assert_nothing_raised{ @hash['a', 'b'] = 3, 4, 5 }
80
- assert_equal({'a' => 3, 'b' => 4}, @hash)
81
- end
77
+ # hash[key1, key2] = value1, value2, value3
78
+ def test_set_slice_instance_method_multiple_keys_odd_values
79
+ assert_nothing_raised{ @hash['a', 'b'] = 3, 4, 5 }
80
+ assert_equal({'a' => 3, 'b' => 4}, @hash)
81
+ end
82
82
 
83
- def test_slice_alias
84
- assert_true(Hash.instance_method(:slice) == Hash.instance_method(:[]))
85
- end
83
+ def test_slice_alias
84
+ assert_true(Hash.instance_method(:slice) == Hash.instance_method(:[]))
85
+ end
86
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
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
91
91
 
92
- def teardown
93
- @hash = nil
94
- end
92
+ def teardown
93
+ @hash = nil
94
+ end
95
95
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashslice
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 8
10
- version: 1.0.8
9
+ - 9
10
+ version: 1.0.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Daniel J. Berger
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-08-31 00:00:00 Z
19
+ date: 2011-09-20 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: test-unit
@@ -26,12 +26,10 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 11
29
+ hash: 3
30
30
  segments:
31
- - 2
32
- - 1
33
31
  - 0
34
- version: 2.1.0
32
+ version: "0"
35
33
  type: :development
36
34
  version_requirements: *id001
37
35
  description: " The hashslice library adds builtin hash slicing to Ruby's Hash class.\n This lets you reference, or assign to, multiple hash keys simultaneously\n via the Hash#[] and Hash#[]= methods, respectively.\n"