0
module ActionController
0
class RouteBuilder #:nodoc:
0
- attr_accessor :separators, :optional_separators
0
+ attr_reader :separators, :optional_separators
0
+ attr_reader :separator_regexp, :nonseparator_regexp, :interval_regexp
0
- self.separators = Routing::SEPARATORS
0
- self.optional_separators = %w( / )
0
- def separator_pattern(inverted = false)
0
- "[#{'^' if inverted}#{Regexp.escape(separators.join)}]"
0
- Regexp.new "(.*?)(#{separators.source}|$)"
0
+ @separators = Routing::SEPARATORS
0
+ @optional_separators = %w( / )
0
- def multiline_regexp?(expression)
0
- expression.options & Regexp::MULTILINE == Regexp::MULTILINE
0
+ @separator_regexp = /[#{Regexp.escape(separators.join)}]/
0
+ @nonseparator_regexp = /\A([^#{Regexp.escape(separators.join)}]+)/
0
+ @interval_regexp = /(.*?)(#{separator_regexp}|$)/
0
# Accepts a "route path" (a string defining a route), and returns the array
0
@@ -30,7 +23,7 @@ module ActionController
0
rest, segments = path, []
0
- segment, rest = segment_for
rest0
+ segment, rest = segment_for
(rest)0
@@ -39,20 +32,20 @@ module ActionController
0
# A factory method that returns a new segment instance appropriate for the
0
# format of the given string.
0
def segment_for(string)
0
- when :controller then ControllerSegment.new(key)
0
- else DynamicSegment.new key
0
- when /\A\*(\w+)/ then PathSegment.new($1.to_sym, :optional => true)
0
- StaticSegment.new($1, :optional => true)
0
- when /\A(#{separator_pattern(:inverted)}+)/ then StaticSegment.new($1)
0
- when Regexp.new(separator_pattern) then
0
- DividerSegment.new($&, :optional => (optional_separators.include? $&))
0
+ key == :controller ? ControllerSegment.new(key) : DynamicSegment.new(key)
0
+ PathSegment.new($1.to_sym, :optional => true)
0
+ StaticSegment.new($1, :optional => true)
0
+ when nonseparator_regexp
0
+ DividerSegment.new($&, :optional => optional_separators.include?($&))
0
[segment, $~.post_match]
0
@@ -98,7 +91,7 @@ module ActionController
0
if requirement.source =~ %r{\A(\\A|\^)|(\\Z|\\z|\$)\Z}
0
raise ArgumentError, "Regexp anchor characters are not allowed in routing requirements: #{requirement.inspect}"
0
- if
multiline_regexp?(requirement)0
+ if
requirement.multiline?0
raise ArgumentError, "Regexp multiline option not allowed in routing requirements: #{requirement.inspect}"
0
segment.regexp = requirement