Sha256: 1ba10e625771c3635ccec15b5c960388187a98c554da5f9963e9b59f00926ac0
Contents?: true
Size: 1.04 KB
Versions: 3
Compression:
Stored size: 1.04 KB
Contents
module Xing module SpecDoc class Patterner def initialize(rails_routes, route_set=nil) @rails_routes = rails_routes @route_set = route_set end attr_reader :rails_routes def route_map @route_map ||= begin ad_routes_array = rails_routes.routes rack_routes_array = rails_routes.set.instance_eval{ @routes } Hash[ rack_routes_array.zip(ad_routes_array) ] end end def route_set @route_set ||= Rails.application.routes.router end def build(req) route_set.recognize(req) do |route, matches, params| rails_route = route_map[route] path_spec = :unrecognized segment_keys = {} if route_map.has_key?(route) rails_route = route_map[route] path_spec = rails_route.path.spec.to_s segment_keys = rails_route.segment_keys return path_spec.sub(/\(\.:format\)/,"") end end return nil end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
xing-backend-specdoc-1.0.0.pre.beta | lib/xing/specdoc/patterner.rb |
xing-backend-specdoc-0.0.2 | lib/xing/specdoc/patterner.rb |
xing-backend-specdoc-0.0.1 | lib/xing/specdoc/patterner.rb |