module Rack::Radar
Constants
- RACK_RADAR__DEFAULT_ENV
- RACK_RADAR__DEFAULT_HOST
- RACK_RADAR__REQUEST_METHODS
- RACK_RADAR__XHR_KEY
- RACK_RADAR__XHR_VAL
Public Instance Methods
__r__session(reset = false)
click to toggle source
# File lib/rack/radar.rb, line 112 def __r__session reset = false (@__r__session ||= {})[app.__id__] = RackRadarSession.new(app) if reset (@__r__session ||= {})[app.__id__] ||= RackRadarSession.new(app) end
__r__with_xhr() { || ... }
click to toggle source
# File lib/rack/radar.rb, line 117 def __r__with_xhr env_xhr = env.has_key?(RACK_RADAR__XHR_KEY) && env[RACK_RADAR__XHR_KEY] env[RACK_RADAR__XHR_KEY] = RACK_RADAR__XHR_VAL unless env_xhr == RACK_RADAR__XHR_VAL yield env[RACK_RADAR__XHR_KEY] = env_xhr if env_xhr end
app(app = nil) { || ... }
click to toggle source
switch session
Rack::Radar
using app based sessions, that’s it, creates sessions based on app __id__. you can test various apps by using ‘app RackApp` to switch between them.
# File lib/rack/radar.rb, line 43 def app app = nil if block_given? @__r__app = yield elsif app @__r__app = app end @__r__app end
env()
click to toggle source
# File lib/rack/radar.rb, line 57 def env @__r__env ||= {} end
follow_redirect!()
click to toggle source
# File lib/rack/radar.rb, line 102 def follow_redirect! last_response.redirect? || raise(RuntimeError, 'Last response is not an redirect!') scheme = last_request.env['HTTPS'] == 'on' ? 'https' : 'http' request(scheme, 'GET', [last_response['Location']], {}, { 'HTTP_REFERER' => last_request.url, 'rack.session' => last_request.env['rack.session'], 'rack.session.options' => last_request.env['rack.session.options'] }) end
map(*args)
click to toggle source
# File lib/rack/radar.rb, line 52 def map *args @__r__base_url = args[0] if args.size > 0 @__r__base_url end
params()
click to toggle source
# File lib/rack/radar.rb, line 61 def params @__r__params ||= {} end
request(scheme, request_method, *args)
click to toggle source
# File lib/rack/radar.rb, line 95 def request scheme, request_method, *args rest, path = args.partition {|a| a.is_a?(Hash)} params = self.params.merge(rest[0] || {}) env = self.env.merge(rest[1] || {}) __r__session.invoke_request(scheme, request_method, @__r__base_url, path, params, env) end
reset_app!()
click to toggle source
reset session for current app. everything will be reset - cookies, headers, authorizations etc.
# File lib/rack/radar.rb, line 71 def reset_app! __r__session :reset end
Also aliased as: reset_browser!
session()
click to toggle source
# File lib/rack/radar.rb, line 65 def session env["rack.session"] ||= {} end