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.
Files changed (5) hide show
  1. data/TODO +4 -0
  2. data/a.rb +13 -4
  3. data/lib/map.rb +21 -2
  4. data/test/map_test.rb +3 -0
  5. metadata +5 -4
data/TODO ADDED
@@ -0,0 +1,4 @@
1
+ todo:
2
+ - map.push(object)
3
+
4
+ done:
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
- p map['a']
5
- p map['a'][0]
6
- p map['a'][0]['b']
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.5' unless defined?(Version)
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
- to_hash.to_yaml(*args, &block)
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
@@ -175,6 +175,9 @@ Testing Map do
175
175
  assert{ a != b}
176
176
  end
177
177
 
178
+ testing 'that JSON.pretty_generate works on maps' do
179
+ end
180
+
178
181
  protected
179
182
  def new_int_map(n = 1024)
180
183
  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: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 5
10
- version: 1.2.5
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-06 00:00:00 -06:00
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: []