map 3.0.0 → 4.0.0
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/Rakefile +12 -11
- data/lib/map.rb +3 -2
- data/map.gemspec +20 -6
- data/test/map_test.rb +12 -1
- metadata +9 -9
data/Rakefile
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
This.rubyforge_project = 'codeforpeople'
|
|
2
2
|
This.author = "Ara T. Howard"
|
|
3
3
|
This.email = "ara.t.howard@gmail.com"
|
|
4
|
-
This.homepage = "
|
|
4
|
+
This.homepage = "https://github.com/ahoward/#{ This.lib }"
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
task :default do
|
|
@@ -59,9 +59,9 @@ end
|
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
task :gemspec do
|
|
62
|
-
ignore_extensions = 'git', 'svn', 'tmp', /sw./, 'bak', 'gem'
|
|
63
|
-
ignore_directories = 'pkg'
|
|
64
|
-
ignore_files = 'test/log'
|
|
62
|
+
ignore_extensions = ['git', 'svn', 'tmp', /sw./, 'bak', 'gem']
|
|
63
|
+
ignore_directories = ['pkg']
|
|
64
|
+
ignore_files = ['test/log']
|
|
65
65
|
|
|
66
66
|
shiteless =
|
|
67
67
|
lambda do |list|
|
|
@@ -87,7 +87,7 @@ task :gemspec do
|
|
|
87
87
|
version = This.version
|
|
88
88
|
files = shiteless[Dir::glob("**/**")]
|
|
89
89
|
executables = shiteless[Dir::glob("bin/*")].map{|exe| File.basename(exe)}
|
|
90
|
-
has_rdoc = true #File.exist?('doc')
|
|
90
|
+
#has_rdoc = true #File.exist?('doc')
|
|
91
91
|
test_files = "test/#{ lib }.rb" if File.file?("test/#{ lib }.rb")
|
|
92
92
|
summary = object.respond_to?(:summary) ? object.summary : "summary: #{ lib } kicks the ass"
|
|
93
93
|
description = object.respond_to?(:description) ? object.description : "description: #{ lib } kicks the ass"
|
|
@@ -117,15 +117,15 @@ task :gemspec do
|
|
|
117
117
|
spec.summary = #{ lib.inspect }
|
|
118
118
|
spec.description = #{ description.inspect }
|
|
119
119
|
|
|
120
|
-
spec.files
|
|
120
|
+
spec.files =\n#{ files.sort.pretty_inspect }
|
|
121
121
|
spec.executables = #{ executables.inspect }
|
|
122
122
|
|
|
123
123
|
spec.require_path = "lib"
|
|
124
124
|
|
|
125
|
-
spec.has_rdoc = #{ has_rdoc.inspect }
|
|
126
125
|
spec.test_files = #{ test_files.inspect }
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
|
|
127
|
+
### spec.add_dependency 'lib', '>= version'
|
|
128
|
+
#### spec.add_dependency 'map'
|
|
129
129
|
|
|
130
130
|
spec.extensions.push(*#{ extensions.inspect })
|
|
131
131
|
|
|
@@ -235,6 +235,7 @@ BEGIN {
|
|
|
235
235
|
require 'erb'
|
|
236
236
|
require 'fileutils'
|
|
237
237
|
require 'rbconfig'
|
|
238
|
+
require 'pp'
|
|
238
239
|
|
|
239
240
|
# fu shortcut
|
|
240
241
|
#
|
|
@@ -292,7 +293,7 @@ BEGIN {
|
|
|
292
293
|
|
|
293
294
|
def unindent(s)
|
|
294
295
|
indent = nil
|
|
295
|
-
s.
|
|
296
|
+
s.each_line do |line|
|
|
296
297
|
next if line =~ %r/^\s*$/
|
|
297
298
|
indent = line[%r/^\s*/] and break
|
|
298
299
|
end
|
|
@@ -309,7 +310,7 @@ BEGIN {
|
|
|
309
310
|
@template = block.call.to_s
|
|
310
311
|
end
|
|
311
312
|
def expand(b=nil)
|
|
312
|
-
ERB.new(Util.unindent(@template)).result(b||@block)
|
|
313
|
+
ERB.new(Util.unindent(@template)).result((b||@block).binding)
|
|
313
314
|
end
|
|
314
315
|
alias_method 'to_s', 'expand'
|
|
315
316
|
end
|
data/lib/map.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
class Map < Hash
|
|
2
|
-
Version = '
|
|
2
|
+
Version = '4.0.0' unless defined?(Version)
|
|
3
3
|
Load = Kernel.method(:load) unless defined?(Load)
|
|
4
4
|
|
|
5
5
|
class << Map
|
|
@@ -241,7 +241,8 @@ class Map < Hash
|
|
|
241
241
|
def self.convert_value(value)
|
|
242
242
|
conversion_methods.each do |method|
|
|
243
243
|
#return convert_value(value.send(method)) if value.respond_to?(method)
|
|
244
|
-
|
|
244
|
+
hashlike = value.is_a?(Hash)
|
|
245
|
+
if hashlike and value.respond_to?(method)
|
|
245
246
|
value = value.send(method)
|
|
246
247
|
break
|
|
247
248
|
end
|
data/map.gemspec
CHANGED
|
@@ -3,25 +3,39 @@
|
|
|
3
3
|
|
|
4
4
|
Gem::Specification::new do |spec|
|
|
5
5
|
spec.name = "map"
|
|
6
|
-
spec.version = "
|
|
6
|
+
spec.version = "4.0.0"
|
|
7
7
|
spec.platform = Gem::Platform::RUBY
|
|
8
8
|
spec.summary = "map"
|
|
9
9
|
spec.description = "description: map kicks the ass"
|
|
10
10
|
|
|
11
|
-
spec.files =
|
|
11
|
+
spec.files =
|
|
12
|
+
["README",
|
|
13
|
+
"Rakefile",
|
|
14
|
+
"TODO",
|
|
15
|
+
"lib",
|
|
16
|
+
"lib/map",
|
|
17
|
+
"lib/map.rb",
|
|
18
|
+
"lib/map/options.rb",
|
|
19
|
+
"lib/map/struct.rb",
|
|
20
|
+
"map.gemspec",
|
|
21
|
+
"test",
|
|
22
|
+
"test/lib",
|
|
23
|
+
"test/lib/testing.rb",
|
|
24
|
+
"test/map_test.rb"]
|
|
25
|
+
|
|
12
26
|
spec.executables = []
|
|
13
27
|
|
|
14
28
|
spec.require_path = "lib"
|
|
15
29
|
|
|
16
|
-
spec.has_rdoc = true
|
|
17
30
|
spec.test_files = nil
|
|
18
|
-
|
|
19
|
-
|
|
31
|
+
|
|
32
|
+
### spec.add_dependency 'lib', '>= version'
|
|
33
|
+
#### spec.add_dependency 'map'
|
|
20
34
|
|
|
21
35
|
spec.extensions.push(*[])
|
|
22
36
|
|
|
23
37
|
spec.rubyforge_project = "codeforpeople"
|
|
24
38
|
spec.author = "Ara T. Howard"
|
|
25
39
|
spec.email = "ara.t.howard@gmail.com"
|
|
26
|
-
spec.homepage = "
|
|
40
|
+
spec.homepage = "https://github.com/ahoward/map"
|
|
27
41
|
end
|
data/test/map_test.rb
CHANGED
|
@@ -232,7 +232,7 @@ Testing Map do
|
|
|
232
232
|
|
|
233
233
|
testing 'that custom conversion methods are coerced - just in case' do
|
|
234
234
|
map = Map.new
|
|
235
|
-
record = Class.new do
|
|
235
|
+
record = Class.new(Hash) do
|
|
236
236
|
def to_map() {:id => 42} end
|
|
237
237
|
end
|
|
238
238
|
map.update(:list => [record.new, record.new])
|
|
@@ -240,6 +240,17 @@ Testing Map do
|
|
|
240
240
|
assert{ map.list.all?{|x| x.id==42} }
|
|
241
241
|
end
|
|
242
242
|
|
|
243
|
+
testing 'that non-hashlike classes do *not* have conversion methods called on them' do
|
|
244
|
+
map = Map.new
|
|
245
|
+
record = Class.new do
|
|
246
|
+
def to_map() {:id => 42} end
|
|
247
|
+
end
|
|
248
|
+
map.update(:record => record.new)
|
|
249
|
+
assert{ !map.record.is_a?(Hash) }
|
|
250
|
+
assert{ !map.record.is_a?(Map) }
|
|
251
|
+
assert{ map.record.is_a?(record) }
|
|
252
|
+
end
|
|
253
|
+
|
|
243
254
|
testing 'that coercion is minimal' do
|
|
244
255
|
map = Map.new
|
|
245
256
|
a = Class.new(Map) do
|
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: 63
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
|
-
-
|
|
7
|
+
- 4
|
|
8
8
|
- 0
|
|
9
9
|
- 0
|
|
10
|
-
version:
|
|
10
|
+
version: 4.0.0
|
|
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-
|
|
18
|
+
date: 2011-05-17 00:00:00 -06:00
|
|
19
19
|
default_executable:
|
|
20
20
|
dependencies: []
|
|
21
21
|
|
|
@@ -28,17 +28,17 @@ extensions: []
|
|
|
28
28
|
extra_rdoc_files: []
|
|
29
29
|
|
|
30
30
|
files:
|
|
31
|
+
- README
|
|
32
|
+
- Rakefile
|
|
33
|
+
- TODO
|
|
34
|
+
- lib/map.rb
|
|
31
35
|
- lib/map/options.rb
|
|
32
36
|
- lib/map/struct.rb
|
|
33
|
-
- lib/map.rb
|
|
34
37
|
- map.gemspec
|
|
35
|
-
- Rakefile
|
|
36
|
-
- README
|
|
37
38
|
- test/lib/testing.rb
|
|
38
39
|
- test/map_test.rb
|
|
39
|
-
- TODO
|
|
40
40
|
has_rdoc: true
|
|
41
|
-
homepage:
|
|
41
|
+
homepage: https://github.com/ahoward/map
|
|
42
42
|
licenses: []
|
|
43
43
|
|
|
44
44
|
post_install_message:
|