Class: Fluoride::Analyzer::Parser::Patterner
- Inherits:
-
Object
- Object
- Fluoride::Analyzer::Parser::Patterner
- Defined in:
- lib/fluoride-analyzer/parser.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#rails_routes ⇒ Object
readonly
Returns the value of attribute rails_routes.
Class Method Summary collapse
Instance Method Summary collapse
- #base_env ⇒ Object
- #build_request(result_env) ⇒ Object
-
#initialize(rails_routes) ⇒ Patterner
constructor
A new instance of Patterner.
- #route_map ⇒ Object
- #route_set ⇒ Object
Constructor Details
#initialize(rails_routes) ⇒ Patterner
Returns a new instance of Patterner.
123 124 125 |
# File 'lib/fluoride-analyzer/parser.rb', line 123 def initialize(rails_routes) @rails_routes = rails_routes end |
Instance Attribute Details
#rails_routes ⇒ Object (readonly)
Returns the value of attribute rails_routes.
126 127 128 |
# File 'lib/fluoride-analyzer/parser.rb', line 126 def rails_routes @rails_routes end |
Class Method Details
.for(rails_routes) ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/fluoride-analyzer/parser.rb', line 99 def self.for(rails_routes) if rails_routes.respond_to? :recognize_path Rails4.new(rails_routes) else Rails3.new(rails_routes) end end |
Instance Method Details
#base_env ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/fluoride-analyzer/parser.rb', line 107 def base_env @base_env ||= { "HTTP_REFERER" => '', "HTTP_COOKIE" => '', "HTTP_AUTHORIZATION" => '', "REQUEST_METHOD" => "GET", 'HTTP_HOST' => '', 'SERVER_NAME' => '', 'SERVER_ADDR' => '', 'SERVER_PORT' => '80', "SCRIPT_NAME" => '', "QUERY_STRING" => '', 'rack.input' => '' #body } end |
#build_request(result_env) ⇒ Object
128 129 130 |
# File 'lib/fluoride-analyzer/parser.rb', line 128 def build_request(result_env) ActionDispatch::Request.new(base_env.merge(request_env)) end |
#route_map ⇒ Object
132 133 134 135 136 137 138 139 |
# File 'lib/fluoride-analyzer/parser.rb', line 132 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 |
#route_set ⇒ Object
141 142 143 144 145 146 147 |
# File 'lib/fluoride-analyzer/parser.rb', line 141 def route_set @route_set ||= begin set = rails_routes.set set end end |