map 5.2.0 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
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 => :v, :a => false}]
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
- puts
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
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  class Map < Hash
3
- Version = '5.2.0' unless defined?(Version)
3
+ Version = '5.3.0' unless defined?(Version)
4
4
  Load = Kernel.method(:load) unless defined?(Load)
5
5
 
6
6
  class << Map
@@ -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
- options.extend(Options) unless options.is_a?(Options)
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
- arguments and arguments.last != self
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 if !popped?
123
+ arguments.pop unless popped?
124
+ ensure
125
+ @popped = true
119
126
  end
120
127
  end
121
128
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "map"
6
- spec.version = "5.2.0"
6
+ spec.version = "5.3.0"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "map"
9
9
  spec.description = "description: map kicks the ass"
@@ -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.2.0
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: 2011-12-29 00:00:00.000000000 Z
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