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
22 23 24 |
# File 'lib/vpim/agent/base.rb', line 22 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.
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/vpim/agent/base.rb', line 52 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:
26 27 28 |
# File 'lib/vpim/agent/base.rb', line 26 def render_css(template, data, ) # :nodoc: data end |
#request_path ⇒ Object
Complete path, as requested by the client. Take care about CGI path rewriting.
31 32 33 34 35 36 37 38 39 |
# File 'lib/vpim/agent/base.rb', line 31 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.
46 47 48 |
# File 'lib/vpim/agent/base.rb', line 46 def script_path request_path.sub(/#{env["PATH_INFO"]}$/, "") end |
#script_url ⇒ Object
URL to the script
65 66 67 |
# File 'lib/vpim/agent/base.rb', line 65 def script_url request.scheme + "://" + host_port + script_path end |