Class: Log::Analyzer::Routes
- Inherits:
-
ActionDispatch::Journey::Routes
- Object
- ActionDispatch::Journey::Routes
- Log::Analyzer::Routes
- Defined in:
- lib/log-analyzer/routes.rb
Instance Method Summary collapse
-
#initialize(routes_text) ⇒ Routes
constructor
A new instance of Routes.
Constructor Details
#initialize(routes_text) ⇒ Routes
Returns a new instance of Routes.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/log-analyzer/routes.rb', line 6 def initialize(routes_text) super() routes_text.scan(regexp) do |request_method, request_path, requirements, constraints| constraints = if constraints.nil? || constraints.empty? [] else eval(constraints) end.map do |constraint| constraint.is_a?(String) ? eval(constraint) : constraint end app = ActionDispatch::Routing::Mapper::Constraints.new(nil, constraints, true) path_pattern = Pattern.from_string(request_method, request_path, requirements) add_route(app, path_pattern, {request_method: /^#{request_method}$/}, {}, {}) end end |