require "rubygems"
require_gem "actionpack"

require 'fake_environment'


#START:store
ActionController::Routing::Routes.draw do |map|
  map.connect ":controller/:action/:id"
end
#END:store

[ "store",
  "store/list",
  "store/display/123"].each do |url|
  
  puts "URL> #{url}"
  req = Request.new(url)
  ActionController::Routing::Routes.recognize!(req)
  puts "@params = " + req.path_parameters.inspect
end

puts "\n\nGénération en cours...."


@map = ActionController::Routing::Route.new(":controller/:action/:id")
@defaults = { :controller => "store" }

#ac.process(req, resp)

def show_route(args)
  components, extras = @map.generate(args, @defaults)
  puts components.join("/")
  puts extras.inspect
end

show_route(:controller => "store")
show_route(:controller => "store", :id => 123)
show_route(:controller => "store", :action => "list")
show_route(:action => "list", :id => 123)
show_route(:controller => "store", :action => "list", :id => 123, :extra => "wibble", :host => "rubygarden.org")

