Class: TDiary::CGICompat
Overview
class CGICompat
provides the CGI compatible interface consumed by plugins as @cgi on
top of TDiary::Request. Behaviour is locked by the shared examples in
spec/support/cgi_compat_shared_examples.rb, which are also applied to
RackCGI, the subclass the dispatcher hands to plugins on the Rack path.
Instance Attribute Summary collapse
Instance Method Summary
collapse
#https?, #mobile_agent?, #param, #remote_addr, #remote_user, #smartphone?, #static_assets?, #tdiary_base_url, #valid?
Constructor Details
#initialize(request) ⇒ CGICompat
Returns a new instance of CGICompat.
14
15
16
17
18
19
20
|
# File 'lib/tdiary/cgi_compat.rb', line 14
def initialize( request )
@request = request
@params = request.cgi_params
end
|
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
22
23
24
|
# File 'lib/tdiary/cgi_compat.rb', line 22
def params
@params
end
|
#request ⇒ Object
Returns the value of attribute request.
12
13
14
|
# File 'lib/tdiary/cgi_compat.rb', line 12
def request
@request
end
|
Instance Method Details
#auth_type ⇒ Object
72
73
74
|
# File 'lib/tdiary/cgi_compat.rb', line 72
def auth_type
env_table['AUTH_TYPE']
end
|
#base_url ⇒ Object
109
110
111
|
# File 'lib/tdiary/cgi_compat.rb', line 109
def base_url
tdiary_base_url
end
|
#cgi_cookies ⇒ Object
38
39
40
|
# File 'lib/tdiary/cgi_compat.rb', line 38
def cgi_cookies
@request.cgi_cookies
end
|
#cgi_params ⇒ Object
the stateful RequestExtension readers delegate to the wrapped
request, so core code reading the request directly sees the same
params Hash and the same hidden-referer state as plugins do
through this facade
34
35
36
|
# File 'lib/tdiary/cgi_compat.rb', line 34
def cgi_params
@request.cgi_params
end
|
#cookies ⇒ Object
50
51
52
53
54
|
# File 'lib/tdiary/cgi_compat.rb', line 50
def cookies
cgi_cookies
end
|
#env ⇒ Object
the env of the wrapped request, for the stateless RequestExtension
readers (remote_addr, https?, tdiary_base_url, ...)
26
27
28
|
# File 'lib/tdiary/cgi_compat.rb', line 26
def env
@request.env
end
|
#env_table ⇒ Object
56
57
58
|
# File 'lib/tdiary/cgi_compat.rb', line 56
def env_table
@request.env
end
|
#gateway_interface ⇒ Object
76
77
78
|
# File 'lib/tdiary/cgi_compat.rb', line 76
def gateway_interface
env_table['GATEWAY_INTERFACE']
end
|
#hide_referer! ⇒ Object
42
43
44
|
# File 'lib/tdiary/cgi_compat.rb', line 42
def hide_referer!
@request.hide_referer!
end
|
#redirect_url ⇒ Object
105
106
107
|
# File 'lib/tdiary/cgi_compat.rb', line 105
def redirect_url
env_table['REDIRECT_URL']
end
|
#referer ⇒ Object
46
47
48
|
# File 'lib/tdiary/cgi_compat.rb', line 46
def referer
@request.referer
end
|
#request_method ⇒ Object
64
65
66
|
# File 'lib/tdiary/cgi_compat.rb', line 64
def request_method
env_table['REQUEST_METHOD']
end
|
#request_uri ⇒ Object
the URL helpers below come from the CGI patches that used to live
in core_ext.rb
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/tdiary/cgi_compat.rb', line 90
def request_uri
_request_uri = env_table['REQUEST_URI']
_script_name = env_table['SCRIPT_NAME']
if !_request_uri || _request_uri == '' || _request_uri == _script_name then
_path_info = env_table['PATH_INFO'] || ''
_query_string = env_table['QUERY_STRING'] || ''
_request_uri = _path_info.include?(_script_name) ? '' : _script_name.dup
_request_uri << _path_info
_request_uri << '?' + _query_string if _query_string != ''
end
_request_uri
end
|
#script_name ⇒ Object
68
69
70
|
# File 'lib/tdiary/cgi_compat.rb', line 68
def script_name
env_table['SCRIPT_NAME']
end
|
#server_name ⇒ Object
80
81
82
|
# File 'lib/tdiary/cgi_compat.rb', line 80
def server_name
env_table['SERVER_NAME']
end
|
#server_port ⇒ Object
84
85
86
|
# File 'lib/tdiary/cgi_compat.rb', line 84
def server_port
env_table['SERVER_PORT'].to_i
end
|
#user_agent ⇒ Object
60
61
62
|
# File 'lib/tdiary/cgi_compat.rb', line 60
def user_agent
env_table['HTTP_USER_AGENT']
end
|