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 +4 -5
- data/lib/map/options.rb +12 -0
- data/map.gemspec +1 -1
- data/test/map_test.rb +18 -0
- metadata +5 -5
data/lib/map.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class Map < Hash
|
2
|
-
Version = '2.
|
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
|
-
|
527
|
-
|
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
|
data/lib/map/options.rb
CHANGED
@@ -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
|
data/map.gemspec
CHANGED
data/test/map_test.rb
CHANGED
@@ -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:
|
4
|
+
hash: 41
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 2.
|
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-
|
18
|
+
date: 2011-04-18 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|