map 2.4.1 → 2.4.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.
Files changed (4) hide show
  1. data/lib/map.rb +5 -2
  2. data/map.gemspec +1 -1
  3. data/test/map_test.rb +10 -0
  4. metadata +4 -4
data/lib/map.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Map < Hash
2
- Version = '2.4.1' unless defined?(Version)
2
+ Version = '2.4.2' unless defined?(Version)
3
3
  Load = Kernel.method(:load) unless defined?(Load)
4
4
 
5
5
  class << Map
@@ -248,16 +248,19 @@ class Map < Hash
248
248
  # maps are aggressive with copy operations. they are all deep copies. make a
249
249
  # new one if you really want a shallow copy
250
250
  #
251
+ # TODO - fallback to shallow if objects cannot be marshal'd....
251
252
  def copy
252
253
  default = self.default
253
254
  self.default = nil
254
- copy = Marshal.load(Marshal.dump(self))
255
+ copy = Marshal.load(Marshal.dump(self)) rescue Dup.bind(self).call()
255
256
  copy.default = default
256
257
  copy
257
258
  ensure
258
259
  self.default = default
259
260
  end
260
261
 
262
+ Dup = instance_method(:dup)
263
+
261
264
  def dup
262
265
  copy
263
266
  end
data/map.gemspec CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "map"
6
- spec.version = "2.4.1"
6
+ spec.version = "2.4.2"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "map"
9
9
  spec.description = "description: map kicks the ass"
data/test/map_test.rb CHANGED
@@ -348,6 +348,16 @@ Testing Map do
348
348
  assert{ m =~ {:k => :v} }
349
349
  end
350
350
 
351
+ testing 'that maps with un-marshal-able objects can be copied' do
352
+ open(__FILE__) do |f|
353
+ f
354
+ m = Map.for(:f => f)
355
+ assert{ m.copy }
356
+ assert{ m.dup }
357
+ assert{ m.clone }
358
+ end
359
+ end
360
+
351
361
  protected
352
362
  def new_int_map(n = 1024)
353
363
  map = assert{ Map.new }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: map
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 4
9
- - 1
10
- version: 2.4.1
9
+ - 2
10
+ version: 2.4.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ara T. Howard
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-10 00:00:00 -07:00
18
+ date: 2011-02-11 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies: []
21
21