map 2.8.0 → 2.9.1

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.
data/lib/map.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Map < Hash
2
- Version = '2.8.0' unless defined?(Version)
2
+ Version = '2.9.1' unless defined?(Version)
3
3
  Load = Kernel.method(:load) unless defined?(Load)
4
4
 
5
5
  class << Map
@@ -522,10 +522,9 @@ class Map < Hash
522
522
  array
523
523
  end
524
524
 
525
- def inspect
526
- array = []
527
- each{|key, val| array << (key.inspect + "=>" + val.inspect)}
528
- string = '{' + array.join(", ") + '}'
525
+ def inspect(*args, &block)
526
+ require 'pp' unless defined?(PP)
527
+ PP.pp(self, '')
529
528
  end
530
529
 
531
530
  # conversions
@@ -150,6 +150,13 @@ def Map.options_for!(*args, &block)
150
150
  Map::Options.for(*args, &block).pop
151
151
  end
152
152
 
153
+ def Map.update_options_for!(args, &block)
154
+ options = Map.options_for!(args)
155
+ block.call(options)
156
+ ensure
157
+ args.push(options)
158
+ end
159
+
153
160
  class << Map
154
161
  src = 'options_for'
155
162
  %w( options opts extract_options ).each do |dst|
@@ -160,4 +167,9 @@ class << Map
160
167
  %w( options! opts! extract_options! ).each do |dst|
161
168
  alias_method(dst, src)
162
169
  end
170
+
171
+ src = 'update_options_for!'
172
+ %w( update_options! update_opts! ).each do |dst|
173
+ alias_method(dst, src)
174
+ end
163
175
  end
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "map"
6
- spec.version = "2.8.0"
6
+ spec.version = "2.9.1"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "map"
9
9
  spec.description = "description: map kicks the ass"
@@ -465,6 +465,24 @@ Testing Map do
465
465
  assert{ Map.new.blank? }
466
466
  end
467
467
 
468
+ testing 'that self referential maps do not make #inspect puke' do
469
+ a = Map.new
470
+ b = Map.new
471
+
472
+ b[:a] = a
473
+ a[:b] = b
474
+
475
+ assert do
476
+ begin
477
+ a.inspect
478
+ b.inspect
479
+ true
480
+ rescue Object
481
+ false
482
+ end
483
+ end
484
+ end
485
+
468
486
  protected
469
487
  def new_int_map(n = 1024)
470
488
  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: 47
4
+ hash: 41
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
- - 8
9
- - 0
10
- version: 2.8.0
8
+ - 9
9
+ - 1
10
+ version: 2.9.1
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-04-08 00:00:00 -06:00
18
+ date: 2011-04-18 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies: []
21
21