map 6.5.3 → 6.5.4

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 (5) hide show
  1. checksums.yaml +8 -8
  2. data/lib/map.rb +3 -3
  3. data/map.gemspec +1 -1
  4. data/test/map_test.rb +11 -0
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YmRlMTBhYTg0YWYwZDU0OGY1Zjk0MWQwYzAyZWQ3NzQyZjMwMTdkNw==
4
+ ZjAxZjU1M2RmNmE0ZWNlY2ZmMjM2ODhhYzg2YTljNTkzYTY0YTUyMg==
5
5
  data.tar.gz: !binary |-
6
- ZWQwNzA0OGNmMzZjOWU5MWZhMTM5NzIzNjBiYmE5NzllZGI4Njg2Ng==
6
+ ZjNlOTJiNmFiYzljZjYzMWFiOGM5YmViM2Y2YTU1NDIwZDIxZjUzNA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NWRjNmFhYWNmMjg1NGZiYjBjZmIxZjgyMGU0N2EyYTg1MTM2N2I1NjBkNmY3
10
- OWRkZmFiOGVlOWE0MmIzMzlmNDA3ZjI1MmM4OWM5YjYzODZmNTc0NmFlODc5
11
- OTcwMTg0NjkyNWNhN2VhMDU1MGI2NDhiZjcwYjM4MGU5YjE4Mzg=
9
+ YzQzMTQ5ZWQ2NTliNWJkZTFjMTk4MWRmMjEwMGM1OTU0NGRlNWYwOGUwYzZj
10
+ OWNhMzZlNzRiYTM1NzJkZTRjYzQ5NDFhNTI3YjY1Y2UzMDA5OGNiZjhjOGM4
11
+ YzlmYWViYzdjNzk4ZjAyOGZhNGIxODlkZjEwZjJmMDA1NWI1Y2Q=
12
12
  data.tar.gz: !binary |-
13
- MTEwOGNiNzY1MjYxYmNkY2Y2NWMxOTE2OTVmOTk3ZjI5YzEyZmE1YjIzODZk
14
- MjY5M2UwZWM1NjEzMmQ1ZGZlYjIzMjQwMWUzZDk5NTIxMmU5MGZlNTdkNzkw
15
- OGI2NDg3MjQ1ODM4MzQyMTU3MWJlMGQxMTBiODQyYjZhZjBjZTM=
13
+ N2M0MWE0YmM1MzBlNjI5MjNkZDhmYjg1NDQ3ZGU0ZTJkNGJlNTM2NDA0YzJl
14
+ ZjY1MjhhODhlZjRmZTNlOGVhMTExOTJiZmJkYWE3Njk5ZDVkZDQ2OTRiMjIw
15
+ ODM5MzQ3NWU0ZjJjY2FmNGI2OTgyMGZhNTBmNjQ1N2U0NzdhYjA=
data/lib/map.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  class Map < Hash
3
- Version = '6.5.3' unless defined?(Version)
3
+ Version = '6.5.4' unless defined?(Version)
4
4
  Load = Kernel.method(:load) unless defined?(Load)
5
5
 
6
6
  class << Map
@@ -774,8 +774,8 @@ class Map < Hash
774
774
  has_key =
775
775
  case collection
776
776
  when Array
777
- key = (Integer(key) rescue -1)
778
- (0...collection.size).include?(key)
777
+ key = (Integer(key) rescue nil)
778
+ !!collection.fetch(key) rescue false
779
779
 
780
780
  when Hash
781
781
  collection.has_key?(key)
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "map"
6
- spec.version = "6.5.3"
6
+ spec.version = "6.5.4"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "map"
9
9
  spec.description = "the awesome ruby container you've always wanted: a string/symbol indifferent ordered hash that works in all rubies"
@@ -365,6 +365,17 @@ Testing Map do
365
365
  assert{ Map.new.tap{|nm| nm.set({})} =~ {} }
366
366
  end
367
367
 
368
+ testing 'that maps support compound key/val getting, setting, and checking with negative array indexes' do
369
+ m = Map.new(a: [b: :c])
370
+ assert { m.get(:a, '-1', :b) == m.get(:a, '-1').get(:b) }
371
+ assert { m.get(:a, '-1', :b) == :c }
372
+
373
+ assert { m.set(:a, '-1', :b, :d) }
374
+ assert { m.get(:a, '-1', :b) == :d }
375
+
376
+ assert { m.has?(:a, '-1', :b) == true}
377
+ end
378
+
368
379
  testing 'that Map#get supports providing a default value in a block' do
369
380
  m = Map.new
370
381
  m.set(:a, :b, :c, 42)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: map
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.5.3
4
+ version: 6.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ara T. Howard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-22 00:00:00.000000000 Z
11
+ date: 2014-06-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ! 'the awesome ruby container you''ve always wanted: a string/symbol
14
14
  indifferent ordered hash that works in all rubies'