map 5.2.0 → 5.3.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/a.rb +4 -26
- data/lib/map.rb +1 -1
- data/lib/map/options.rb +10 -3
- data/map.gemspec +1 -1
- data/test/map_test.rb +3 -0
- metadata +2 -2
data/a.rb
CHANGED
@@ -1,31 +1,9 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
require 'map'
|
2
|
+
require './lib/map.rb'
|
3
3
|
|
4
|
-
args = [0, 1, {:k
|
5
|
-
opts = Map.options_for!(args)
|
6
|
-
|
7
|
-
#p args.object_id
|
8
|
-
#p opts.arguments.object_id
|
9
|
-
#p !args.last.is_a?(Hash)
|
10
|
-
#puts
|
11
|
-
#puts
|
12
|
-
|
13
|
-
new_args = [0, 1, opts]
|
14
|
-
new_opts = Map.options_for!(new_args)
|
15
|
-
#p new_opts.popped?
|
16
|
-
p new_args
|
17
|
-
p args
|
18
|
-
#p !new_args.last.is_a?(Hash)
|
19
|
-
#p new_opts.arguments.object_id
|
20
|
-
#p new_args.object_id
|
4
|
+
args = [0, 1, {:k=>:v, :a=>false}]
|
21
5
|
|
22
|
-
|
23
|
-
puts
|
24
|
-
__END__
|
25
|
-
|
26
|
-
puts '---'
|
6
|
+
opts = Map.options_for!(args)
|
27
7
|
|
28
|
-
p opts.arguments
|
29
8
|
p args
|
30
|
-
|
31
|
-
|
9
|
+
p opts
|
data/lib/map.rb
CHANGED
data/lib/map/options.rb
CHANGED
@@ -15,7 +15,11 @@ class Map
|
|
15
15
|
raise(ArgumentError, arg.inspect) unless arg.respond_to?(:to_hash)
|
16
16
|
arg.to_hash
|
17
17
|
end
|
18
|
-
|
18
|
+
unless options.is_a?(Options)
|
19
|
+
options = Map.for(options)
|
20
|
+
options.extend(Options)
|
21
|
+
end
|
22
|
+
raise unless options.is_a?(Map)
|
19
23
|
options
|
20
24
|
end
|
21
25
|
|
@@ -111,11 +115,14 @@ class Map
|
|
111
115
|
end
|
112
116
|
|
113
117
|
def popped?
|
114
|
-
|
118
|
+
@popped = false unless defined?(@popped)
|
119
|
+
arguments and arguments.last!=self and @popped
|
115
120
|
end
|
116
121
|
|
117
122
|
def pop!
|
118
|
-
arguments.pop
|
123
|
+
arguments.pop unless popped?
|
124
|
+
ensure
|
125
|
+
@popped = true
|
119
126
|
end
|
120
127
|
end
|
121
128
|
|
data/map.gemspec
CHANGED
data/test/map_test.rb
CHANGED
@@ -271,6 +271,7 @@ Testing Map do
|
|
271
271
|
%w( options_for options opts ).each do |method|
|
272
272
|
args = [0,1, {:k => :v, :a => false}]
|
273
273
|
opts = assert{ Map.send(method, args) }
|
274
|
+
assert{ opts.is_a?(Map) }
|
274
275
|
assert{ opts.getopt(:k)==:v }
|
275
276
|
assert{ opts.getopt(:a)==false }
|
276
277
|
assert{ opts.getopt(:b, :default => 42)==42 }
|
@@ -282,10 +283,12 @@ Testing Map do
|
|
282
283
|
%w( options_for! options! opts! ).each do |method|
|
283
284
|
args = [0,1, {:k => :v, :a => false}]
|
284
285
|
opts = assert{ Map.send(method, args) }
|
286
|
+
assert{ opts.is_a?(Map) }
|
285
287
|
assert{ !args.last.is_a?(Hash) }
|
286
288
|
|
287
289
|
new_args = [0,1, opts]
|
288
290
|
new_opts = assert{ Map.send(method, new_args) }
|
291
|
+
assert{ new_opts.is_a?(Map) }
|
289
292
|
assert{ !new_args.last.is_a?(Hash) }
|
290
293
|
end
|
291
294
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: map
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-03-17 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! 'description: map kicks the ass'
|
15
15
|
email: ara.t.howard@gmail.com
|