Class: Vpim::Agent::Base
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Vpim::Agent::Base
- Defined in:
- lib/vpim/agent/base.rb
Direct Known Subclasses
Instance Method Summary collapse
- #css(template) ⇒ Object
-
#host_port ⇒ Object
URL-ready form of the host and port, where the port isn’t specified if it is the default for the URL scheme.
-
#render_css(template, data, options) ⇒ Object
:nodoc:.
-
#request_path ⇒ Object
Complete path, as requested by the client.
-
#script_path ⇒ Object
Complete path, as requested by the client, without the env’s PATH_INFO.
-
#script_url ⇒ Object
URL to the script.
Instance Method Details
#css(template) ⇒ Object
23 24 25 |
# File 'lib/vpim/agent/base.rb', line 23 def css(template) render :css, template, {} end |
#host_port ⇒ Object
URL-ready form of the host and port, where the port isn’t specified if it is the default for the URL scheme.
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/vpim/agent/base.rb', line 53 def host_port r = request host_port = r.host if r.scheme == "https" && r.port != 443 || r.scheme == "http" && r.port != 80 host_port << ":#{r.port}" end host_port end |
#render_css(template, data, options) ⇒ Object
:nodoc:
27 28 29 |
# File 'lib/vpim/agent/base.rb', line 27 def render_css(template, data, ) # :nodoc: data end |
#request_path ⇒ Object
Complete path, as requested by the client. Take care about CGI path rewriting.
32 33 34 35 36 37 38 39 40 |
# File 'lib/vpim/agent/base.rb', line 32 def request_path # Using .to_s because rack/request.rb does, though I think the Rack # spec requires these to be strings already. begin URI.parse(env["SCRIPT_URI"].to_s).path rescue env["SCRIPT_NAME"].to_s + env["PATH_INFO"].to_s end end |
#script_path ⇒ Object
Complete path, as requested by the client, without the env’s PATH_INFO. This is the path to whatever is “handling” the request.
Recent discussions on how PATH_INFO must be decoded leads me to think this might not work if the path had any URL encoded characters in it.
47 48 49 |
# File 'lib/vpim/agent/base.rb', line 47 def script_path request_path.sub(/#{env["PATH_INFO"]}$/, "") end |
#script_url ⇒ Object
URL to the script
66 67 68 |
# File 'lib/vpim/agent/base.rb', line 66 def script_url request.scheme + "://" + host_port + script_path end |