1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

ask the strexp for the ast

This commit is contained in:
Aaron Patterson 2014-05-29 15:16:40 -07:00
parent 7da98d0a59
commit eabe504cdf
2 changed files with 7 additions and 3 deletions

View file

@ -5,17 +5,16 @@ module ActionDispatch
attr_reader :spec, :requirements, :anchored
def initialize(strexp)
parser = Journey::Parser.new
@anchored = true
case strexp
when String
parser = Journey::Parser.new
@spec = parser.parse(strexp)
@requirements = {}
@separators = "/.?"
when Router::Strexp
@spec = parser.parse(strexp.path)
@spec = strexp.ast
@requirements = strexp.requirements
@separators = strexp.separators.join
@anchored = strexp.anchor

View file

@ -15,6 +15,11 @@ module ActionDispatch
@anchor = anchor
end
def ast
parser = Journey::Parser.new
parser.parse path
end
def names
@path.scan(/:\w+/).map { |s| s.tr(':', '') }
end