From e05701cda762b5807f71e60ec40e49d87774c85f Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 31 Oct 2011 15:30:26 -0400 Subject: [PATCH] fixing scanner for path tokenization. fixes #1 --- lib/journey/nfa/transition_table.rb | 2 -- lib/journey/scanner.rb | 2 +- test/test_router.rb | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/journey/nfa/transition_table.rb b/lib/journey/nfa/transition_table.rb index 571c122..6433b3c 100644 --- a/lib/journey/nfa/transition_table.rb +++ b/lib/journey/nfa/transition_table.rb @@ -72,8 +72,6 @@ def generalized_table end end - final_state = state_id.length + 1 - final_groups = state_id.keys.find_all { |s| s.sort.last == accepting } diff --git a/lib/journey/scanner.rb b/lib/journey/scanner.rb index 6f31b8a..d411086 100644 --- a/lib/journey/scanner.rb +++ b/lib/journey/scanner.rb @@ -47,7 +47,7 @@ def scan [:DOT, text] when text = @ss.scan(/:\w+/) [:SYMBOL, text] - when text = @ss.scan(/\w+/) + when text = @ss.scan(/[\w-]+/) [:LITERAL, text] # any char when text = @ss.scan(/./) diff --git a/test/test_router.rb b/test/test_router.rb index 649cc90..3946189 100644 --- a/test/test_router.rb +++ b/test/test_router.rb @@ -28,6 +28,23 @@ def hello end end + def test_dashes + klass = FakeRequestFeeler.new nil + router = Router.new(routes, {}) + + exp = Router::Strexp.new '/foo-bar-baz', {}, ['/.?'] + path = Path::Pattern.new exp + + routes.add_route nil, path, {}, {:id => nil}, {} + + env = rails_env 'PATH_INFO' => '/foo-bar-baz' + called = false + router.recognize(env) do |r, _, params| + called = true + end + assert called + end + def test_request_class_and_requirements_success klass = FakeRequestFeeler.new nil router = Router.new(routes, {:request_class => klass })