mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-19 16:50:12 +01:00
Vendoring Rails 2.3.5
This commit is contained in:
parent
3e83d19299
commit
f8779795ce
943 changed files with 56503 additions and 61351 deletions
|
|
@ -3,7 +3,11 @@ module ActionController
|
|||
class Segment #:nodoc:
|
||||
RESERVED_PCHAR = ':@&=+$,;'
|
||||
SAFE_PCHAR = "#{URI::REGEXP::PATTERN::UNRESERVED}#{RESERVED_PCHAR}"
|
||||
UNSAFE_PCHAR = Regexp.new("[^#{SAFE_PCHAR}]", false, 'N').freeze
|
||||
if RUBY_VERSION >= '1.9'
|
||||
UNSAFE_PCHAR = Regexp.new("[^#{SAFE_PCHAR}]", false).freeze
|
||||
else
|
||||
UNSAFE_PCHAR = Regexp.new("[^#{SAFE_PCHAR}]", false, 'N').freeze
|
||||
end
|
||||
|
||||
# TODO: Convert :is_optional accessor to read only
|
||||
attr_accessor :is_optional
|
||||
|
|
@ -191,23 +195,19 @@ module ActionController
|
|||
end
|
||||
|
||||
def regexp_chunk
|
||||
if regexp
|
||||
if regexp_has_modifiers?
|
||||
"(#{regexp.to_s})"
|
||||
else
|
||||
"(#{regexp.source})"
|
||||
end
|
||||
else
|
||||
"([^#{Routing::SEPARATORS.join}]+)"
|
||||
end
|
||||
regexp ? regexp_string : default_regexp_chunk
|
||||
end
|
||||
|
||||
def regexp_string
|
||||
regexp_has_modifiers? ? "(#{regexp.to_s})" : "(#{regexp.source})"
|
||||
end
|
||||
|
||||
def default_regexp_chunk
|
||||
"([^#{Routing::SEPARATORS.join}]+)"
|
||||
end
|
||||
|
||||
def number_of_captures
|
||||
if regexp
|
||||
regexp.number_of_captures + 1
|
||||
else
|
||||
1
|
||||
end
|
||||
regexp ? regexp.number_of_captures + 1 : 1
|
||||
end
|
||||
|
||||
def build_pattern(pattern)
|
||||
|
|
@ -244,10 +244,6 @@ module ActionController
|
|||
"(?i-:(#{(regexp || Regexp.union(*possible_names)).source}))"
|
||||
end
|
||||
|
||||
def number_of_captures
|
||||
1
|
||||
end
|
||||
|
||||
# Don't URI.escape the controller name since it may contain slashes.
|
||||
def interpolation_chunk(value_code = local_name)
|
||||
"\#{#{value_code}.to_s}"
|
||||
|
|
@ -289,8 +285,8 @@ module ActionController
|
|||
"params[:#{key}] = PathSegment::Result.new_escaped((match[#{next_capture}]#{" || " + default.inspect if default}).split('/'))#{" if match[" + next_capture + "]" if !default}"
|
||||
end
|
||||
|
||||
def regexp_chunk
|
||||
regexp || "(.*)"
|
||||
def default_regexp_chunk
|
||||
"(.*)"
|
||||
end
|
||||
|
||||
def number_of_captures
|
||||
|
|
@ -308,5 +304,40 @@ module ActionController
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
# The OptionalFormatSegment allows for any resource route to have an optional
|
||||
# :format, which decreases the amount of routes created by 50%.
|
||||
class OptionalFormatSegment < DynamicSegment
|
||||
|
||||
def initialize(key = nil, options = {})
|
||||
super(:format, {:optional => true}.merge(options))
|
||||
end
|
||||
|
||||
def interpolation_chunk
|
||||
"." + super
|
||||
end
|
||||
|
||||
def regexp_chunk
|
||||
'/|(\.[^/?\.]+)?'
|
||||
end
|
||||
|
||||
def to_s
|
||||
'(.:format)?'
|
||||
end
|
||||
|
||||
def extract_value
|
||||
"#{local_name} = options[:#{key}] && options[:#{key}].to_s.downcase"
|
||||
end
|
||||
|
||||
#the value should not include the period (.)
|
||||
def match_extraction(next_capture)
|
||||
%[
|
||||
if (m = match[#{next_capture}])
|
||||
params[:#{key}] = URI.unescape(m.from(1))
|
||||
end
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue