map 1.2.5 → 1.2.6
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/TODO +4 -0
- data/a.rb +13 -4
- data/lib/map.rb +21 -2
- data/test/map_test.rb +3 -0
- metadata +5 -4
data/a.rb
CHANGED
@@ -1,6 +1,15 @@
|
|
1
|
+
$:.push('./lib')
|
2
|
+
require 'map'
|
3
|
+
require 'rubygems'
|
4
|
+
require 'json'
|
5
|
+
require 'active_support'
|
6
|
+
require 'tagz'
|
1
7
|
|
2
|
-
map = Map(:a => [{:b => 42}])
|
3
8
|
|
4
|
-
|
5
|
-
|
6
|
-
|
9
|
+
map = Map.new
|
10
|
+
42.times{|i| map[i] = Map[:a,0, :b,1, :c,2] }
|
11
|
+
json = JSON.pretty_generate(map)
|
12
|
+
|
13
|
+
|
14
|
+
json = JSON.pretty_generate(map)
|
15
|
+
puts json
|
data/lib/map.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class Map < Hash
|
2
|
-
Version = '1.2.
|
2
|
+
Version = '1.2.6' unless defined?(Version)
|
3
3
|
Load = Kernel.method(:load) unless defined?(Load)
|
4
4
|
|
5
5
|
class << Map
|
@@ -382,7 +382,26 @@ class Map < Hash
|
|
382
382
|
end
|
383
383
|
|
384
384
|
def to_yaml(*args, &block)
|
385
|
-
|
385
|
+
as_hash{ super }
|
386
|
+
end
|
387
|
+
|
388
|
+
def to_json(*args, &block)
|
389
|
+
as_hash{ super }
|
390
|
+
end
|
391
|
+
|
392
|
+
def as_json(*args, &block)
|
393
|
+
as_hash{ super }
|
394
|
+
end
|
395
|
+
|
396
|
+
def as_hash
|
397
|
+
@class = Hash
|
398
|
+
yield
|
399
|
+
ensure
|
400
|
+
@class = nil
|
401
|
+
end
|
402
|
+
|
403
|
+
def class
|
404
|
+
@class || super
|
386
405
|
end
|
387
406
|
|
388
407
|
def to_array
|
data/test/map_test.rb
CHANGED
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: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 6
|
10
|
+
version: 1.2.6
|
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: 2010-10-
|
18
|
+
date: 2010-10-09 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- README
|
35
35
|
- test/lib/testing.rb
|
36
36
|
- test/map_test.rb
|
37
|
+
- TODO
|
37
38
|
has_rdoc: true
|
38
39
|
homepage: http://github.com/ahoward/map/tree/master
|
39
40
|
licenses: []
|