Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 341
- Log:
Lots of changes to Hub to make it Rails 2.3.11 compatible. This is being
checked in as one large changeset because it doesn't really split down into
smaller components without having something that doesn't function in the
intermediate steps.
- Author:
- rool
- Date:
- Sat Mar 19 19:11:39 +0000 2011
- Size:
- 2127 Bytes
1 | ######################################################################## |
2 | # File:: rack.rb |
3 | # (C):: http://thewebfellas.com/blog/2010/7/15/rails-2-3-8-rack-1-1-and-the-curious-case-of-the-missing-quotes |
4 | # |
5 | # Purpose:: Fix the broken Rack version upon which Rails 2.3.x versions |
6 | # above 2.3.5 annoyingly require. |
7 | # ---------------------------------------------------------------------- |
8 | # 27-Jan-2011 (ADH): Created. |
9 | ######################################################################## |
10 | |
11 | module Rack |
12 | module Utils |
13 | def parse_query(qs, d = nil) |
14 | params = {} |
15 | |
16 | (qs || '').split(d ? /[#{d}] */n : DEFAULT_SEP).each do |p| |
17 | k, v = p.split('=', 2).map { |x| unescape(x) } |
18 | if cur = params[k] |
19 | if cur.class == Array |
20 | params[k] << v |
21 | else |
22 | params[k] = [cur, v] |
23 | end |
24 | else |
25 | params[k] = v |
26 | end |
27 | end |
28 | |
29 | return params |
30 | end |
31 | module_function :parse_query |
32 | |
33 | def normalize_params(params, name, v = nil) |
34 | name =~ %r(\A[\[\]]*([^\[\]]+)\]*) |
35 | k = $1 || '' |
36 | after = $' || '' |
37 | |
38 | return if k.empty? |
39 | |
40 | if after == "" |
41 | params[k] = v |
42 | elsif after == "[]" |
43 | params[k] ||= [] |
44 | raise TypeError, "expected Array (got #{params[k].class.name}) for param `#{k}'" unless params[k].is_a?(Array) |
45 | params[k] << v |
46 | elsif after =~ %r(^\[\]\[([^\[\]]+)\]$) || after =~ %r(^\[\](.+)$) |
47 | child_key = $1 |
48 | params[k] ||= [] |
49 | raise TypeError, "expected Array (got #{params[k].class.name}) for param `#{k}'" unless params[k].is_a?(Array) |
50 | if params[k].last.is_a?(Hash) && !params[k].last.key?(child_key) |
51 | normalize_params(params[k].last, child_key, v) |
52 | else |
53 | params[k] << normalize_params({}, child_key, v) |
54 | end |
55 | else |
56 | params[k] ||= {} |
57 | raise TypeError, "expected Hash (got #{params[k].class.name}) for param `#{k}'" unless params[k].is_a?(Hash) |
58 | params[k] = normalize_params(params[k], after, v) |
59 | end |
60 | |
61 | return params |
62 | end |
63 | module_function :normalize_params |
64 | end |
65 | end |