rack-mount 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -35,7 +35,7 @@ module Rack::Mount
35
35
  def url(*args)
36
36
  named_route, params, recall, options = extract_params!(*args)
37
37
 
38
- options[:parameterize] ||= lambda { |name, value| Utils.escape_uri(value) }
38
+ options[:parameterize] ||= lambda { |name, param| Utils.escape_uri(param) }
39
39
 
40
40
  unless result = generate(:path_info, named_route, params, recall, options)
41
41
  return
@@ -46,7 +46,7 @@ module Rack::Mount
46
46
  if scanner.scan(/\?:<([^>]+)>/)
47
47
  @names << scanner[1]
48
48
  elsif scanner.scan(/\?:/)
49
- # ignore
49
+ # ignore noncapture
50
50
  else
51
51
  @names << nil
52
52
  end
@@ -77,19 +77,13 @@ module Rack::Mount
77
77
  }.join("&")
78
78
  when Hash
79
79
  value.map { |k, v|
80
- build_nested_query(v, prefix ? "#{prefix}[#{k}]" : k)
80
+ build_nested_query(v, prefix ? "#{prefix}[#{Rack::Utils.escape(k)}]" : Rack::Utils.escape(k))
81
81
  }.join("&")
82
82
  when String
83
83
  raise ArgumentError, "value must be a Hash" if prefix.nil?
84
- "#{Rack::Utils.escape(prefix)}=#{Rack::Utils.escape(value)}"
85
- when NilClass
86
- Rack::Utils.escape(prefix)
84
+ "#{prefix}=#{Rack::Utils.escape(value)}"
87
85
  else
88
- if value.respond_to?(:to_param)
89
- build_nested_query(value.to_param.to_s, prefix)
90
- else
91
- Rack::Utils.escape(prefix)
92
- end
86
+ prefix
93
87
  end
94
88
  end
95
89
  module_function :build_nested_query
@@ -291,16 +291,43 @@ class Multimap
291
291
  invert[value]
292
292
  end
293
293
 
294
- def delete_if(&block) #:nodoc:
295
- @hash.delete_if(&block)
294
+ # call-seq:
295
+ # map.delete_if {| key, value | block } -> map
296
+ #
297
+ # Deletes every key-value pair from <i>map</i> for which <i>block</i>
298
+ # evaluates to <code>true</code>.
299
+ #
300
+ # map = Multimap["a" => 100, "b" => [200, 300]]
301
+ # map.delete_if {|key, value| value >= 300 }
302
+ # #=> Multimap["a" => 100, "b" => 200]
303
+ #
304
+ def delete_if
305
+ each_association do |key, container|
306
+ container.delete_if do |value|
307
+ yield [key, value]
308
+ end
309
+ end
296
310
  self
297
311
  end
298
312
 
299
- def reject(&block) #:nodoc:
313
+ # call-seq:
314
+ # map.reject {| key, value | block } -> map
315
+ #
316
+ # Same as <code>Multimap#delete_if</code>, but works on (and returns) a
317
+ # copy of the <i>map</i>. Equivalent to
318
+ # <code><i>map</i>.dup.delete_if</code>.
319
+ #
320
+ def reject(&block)
300
321
  dup.delete_if(&block)
301
322
  end
302
323
 
303
- def reject!(&block) #:nodoc:
324
+ # call-seq:
325
+ # map.reject! {| key, value | block } -> map or nil
326
+ #
327
+ # Equivalent to <code>Multimap#delete_if</code>, but returns
328
+ # <code>nil</code> if no changes were made.
329
+ #
330
+ def reject!(&block)
304
331
  old_size = size
305
332
  delete_if(&block)
306
333
  old_size == size ? nil : self
@@ -10,7 +10,7 @@ module Reginald
10
10
 
11
11
  class << self
12
12
  begin
13
- eval('/(?<foo>.*)/').named_captures
13
+ eval('foo = /(?<foo>.*)/').named_captures
14
14
 
15
15
  def regexp_supports_named_captures?
16
16
  true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-mount
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Peek
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-29 00:00:00 -06:00
12
+ date: 2009-12-02 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency