airbrake 3.1.6 → 11.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/airbrake.rb +23 -150
- data/lib/airbrake/capistrano.rb +6 -42
- data/lib/airbrake/capistrano/capistrano2.rb +40 -0
- data/lib/airbrake/capistrano/capistrano3.rb +23 -0
- data/lib/airbrake/delayed_job.rb +66 -0
- data/lib/airbrake/logger.rb +103 -0
- data/lib/airbrake/rack.rb +30 -45
- data/lib/airbrake/rack/context_filter.rb +65 -0
- data/lib/airbrake/rack/http_headers_filter.rb +44 -0
- data/lib/airbrake/rack/http_params_filter.rb +27 -0
- data/lib/airbrake/rack/instrumentable.rb +136 -0
- data/lib/airbrake/rack/middleware.rb +102 -0
- data/lib/airbrake/rack/request_body_filter.rb +33 -0
- data/lib/airbrake/rack/request_store.rb +34 -0
- data/lib/airbrake/rack/route_filter.rb +51 -0
- data/lib/airbrake/rack/session_filter.rb +25 -0
- data/lib/airbrake/rack/user.rb +74 -0
- data/lib/airbrake/rack/user_filter.rb +25 -0
- data/lib/airbrake/rails.rb +25 -31
- data/lib/airbrake/rails/action_cable.rb +35 -0
- data/lib/airbrake/rails/action_cable/notify_callback.rb +22 -0
- data/lib/airbrake/rails/action_controller.rb +40 -0
- data/lib/airbrake/rails/action_controller_notify_subscriber.rb +32 -0
- data/lib/airbrake/rails/action_controller_performance_breakdown_subscriber.rb +51 -0
- data/lib/airbrake/rails/action_controller_route_subscriber.rb +33 -0
- data/lib/airbrake/rails/active_job.rb +50 -0
- data/lib/airbrake/rails/active_record.rb +36 -0
- data/lib/airbrake/rails/active_record_subscriber.rb +46 -0
- data/lib/airbrake/rails/app.rb +78 -0
- data/lib/airbrake/rails/backtrace_cleaner.rb +23 -0
- data/lib/airbrake/rails/curb.rb +32 -0
- data/lib/airbrake/rails/event.rb +81 -0
- data/lib/airbrake/rails/excon_subscriber.rb +25 -0
- data/lib/airbrake/rails/http.rb +14 -0
- data/lib/airbrake/rails/http_client.rb +16 -0
- data/lib/airbrake/rails/net_http.rb +18 -0
- data/lib/airbrake/rails/railtie.rb +151 -0
- data/lib/airbrake/rails/typhoeus.rb +16 -0
- data/lib/airbrake/rake.rb +65 -0
- data/lib/airbrake/rake/tasks.rb +112 -0
- data/lib/airbrake/resque.rb +61 -0
- data/lib/airbrake/shoryuken.rb +54 -0
- data/lib/airbrake/sidekiq.rb +55 -0
- data/lib/airbrake/sidekiq/retryable_jobs_filter.rb +53 -0
- data/lib/airbrake/sneakers.rb +72 -0
- data/lib/airbrake/version.rb +5 -1
- data/lib/generators/airbrake_generator.rb +25 -0
- data/lib/generators/airbrake_initializer.rb.erb +80 -0
- metadata +206 -259
- data/CHANGELOG +0 -944
- data/Gemfile +0 -3
- data/Guardfile +0 -6
- data/INSTALL +0 -20
- data/MIT-LICENSE +0 -22
- data/README.md +0 -556
- data/README_FOR_HEROKU_ADDON.md +0 -94
- data/Rakefile +0 -223
- data/SUPPORTED_RAILS_VERSIONS +0 -38
- data/TESTING.md +0 -41
- data/airbrake.gemspec +0 -40
- data/bin/airbrake +0 -12
- data/features/metal.feature +0 -18
- data/features/rack.feature +0 -60
- data/features/rails.feature +0 -272
- data/features/rails_with_js_notifier.feature +0 -97
- data/features/rake.feature +0 -27
- data/features/sinatra.feature +0 -29
- data/features/step_definitions/file_steps.rb +0 -10
- data/features/step_definitions/metal_steps.rb +0 -23
- data/features/step_definitions/rack_steps.rb +0 -23
- data/features/step_definitions/rails_application_steps.rb +0 -478
- data/features/step_definitions/rake_steps.rb +0 -17
- data/features/support/airbrake_shim.rb.template +0 -16
- data/features/support/env.rb +0 -18
- data/features/support/matchers.rb +0 -35
- data/features/support/rails.rb +0 -201
- data/features/support/rake/Rakefile +0 -68
- data/features/support/terminal.rb +0 -107
- data/features/user_informer.feature +0 -63
- data/generators/airbrake/airbrake_generator.rb +0 -94
- data/generators/airbrake/lib/insert_commands.rb +0 -34
- data/generators/airbrake/lib/rake_commands.rb +0 -24
- data/generators/airbrake/templates/airbrake_tasks.rake +0 -25
- data/generators/airbrake/templates/capistrano_hook.rb +0 -6
- data/generators/airbrake/templates/initializer.rb +0 -6
- data/install.rb +0 -1
- data/lib/airbrake/backtrace.rb +0 -108
- data/lib/airbrake/cli/client.rb +0 -68
- data/lib/airbrake/cli/options.rb +0 -41
- data/lib/airbrake/cli/printer.rb +0 -30
- data/lib/airbrake/cli/project.rb +0 -17
- data/lib/airbrake/cli/project_factory.rb +0 -36
- data/lib/airbrake/cli/runner.rb +0 -48
- data/lib/airbrake/cli/validator.rb +0 -8
- data/lib/airbrake/configuration.rb +0 -311
- data/lib/airbrake/extensions/blank.rb +0 -73
- data/lib/airbrake/notice.rb +0 -390
- data/lib/airbrake/rails/action_controller_catcher.rb +0 -30
- data/lib/airbrake/rails/controller_methods.rb +0 -87
- data/lib/airbrake/rails/error_lookup.rb +0 -33
- data/lib/airbrake/rails/javascript_notifier.rb +0 -47
- data/lib/airbrake/rails/middleware/exceptions_catcher.rb +0 -33
- data/lib/airbrake/rails3_tasks.rb +0 -98
- data/lib/airbrake/railtie.rb +0 -48
- data/lib/airbrake/rake_handler.rb +0 -71
- data/lib/airbrake/sender.rb +0 -128
- data/lib/airbrake/shared_tasks.rb +0 -47
- data/lib/airbrake/tasks.rb +0 -83
- data/lib/airbrake/user_informer.rb +0 -27
- data/lib/airbrake_tasks.rb +0 -64
- data/lib/rails/generators/airbrake/airbrake_generator.rb +0 -100
- data/lib/templates/javascript_notifier.erb +0 -15
- data/lib/templates/rescue.erb +0 -91
- data/rails/init.rb +0 -1
- data/resources/README.md +0 -34
- data/resources/ca-bundle.crt +0 -3376
- data/script/integration_test.rb +0 -38
- data/test/airbrake_2_3.xsd +0 -88
- data/test/airbrake_tasks_test.rb +0 -170
- data/test/backtrace_test.rb +0 -162
- data/test/capistrano_test.rb +0 -34
- data/test/catcher_test.rb +0 -333
- data/test/configuration_test.rb +0 -233
- data/test/helper.rb +0 -263
- data/test/javascript_notifier_test.rb +0 -51
- data/test/logger_test.rb +0 -79
- data/test/notice_test.rb +0 -490
- data/test/notifier_test.rb +0 -276
- data/test/rack_test.rb +0 -58
- data/test/rails_initializer_test.rb +0 -36
- data/test/recursion_test.rb +0 -10
- data/test/sender_test.rb +0 -288
- data/test/user_informer_test.rb +0 -29
@@ -1,73 +0,0 @@
|
|
1
|
-
# stolen from ActiveSupport
|
2
|
-
|
3
|
-
class Object
|
4
|
-
unless method_defined?(:blank?)
|
5
|
-
def blank?
|
6
|
-
respond_to?(:empty?) ? empty? : !self
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
unless method_defined?(:present?)
|
11
|
-
def present?
|
12
|
-
!blank?
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
unless method_defined?(:presence)
|
17
|
-
def presence
|
18
|
-
self if present?
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class NilClass
|
24
|
-
unless method_defined?(:blank?)
|
25
|
-
def blank?
|
26
|
-
true
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
class FalseClass
|
32
|
-
unless method_defined?(:blank?)
|
33
|
-
def blank?
|
34
|
-
true
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
class TrueClass
|
40
|
-
unless method_defined?(:blank?)
|
41
|
-
def blank?
|
42
|
-
false
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
class Array
|
48
|
-
unless method_defined?(:blank?)
|
49
|
-
alias_method :blank?, :empty?
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
class Hash
|
54
|
-
unless method_defined?(:blank?)
|
55
|
-
alias_method :blank?, :empty?
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
class String
|
60
|
-
unless method_defined?(:blank?)
|
61
|
-
def blank?
|
62
|
-
self !~ /[^[:space:]]/
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
class Numeric
|
68
|
-
unless method_defined?(:blank?)
|
69
|
-
def blank?
|
70
|
-
false
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
data/lib/airbrake/notice.rb
DELETED
@@ -1,390 +0,0 @@
|
|
1
|
-
require 'builder'
|
2
|
-
require 'socket'
|
3
|
-
|
4
|
-
module Airbrake
|
5
|
-
class Notice
|
6
|
-
|
7
|
-
class << self
|
8
|
-
def attr_reader_with_tracking(*names)
|
9
|
-
attr_readers.concat(names)
|
10
|
-
attr_reader_without_tracking(*names)
|
11
|
-
end
|
12
|
-
|
13
|
-
alias_method :attr_reader_without_tracking, :attr_reader
|
14
|
-
alias_method :attr_reader, :attr_reader_with_tracking
|
15
|
-
|
16
|
-
|
17
|
-
def attr_readers
|
18
|
-
@attr_readers ||= []
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
# The exception that caused this notice, if any
|
23
|
-
attr_reader :exception
|
24
|
-
|
25
|
-
# The API key for the project to which this notice should be sent
|
26
|
-
attr_reader :api_key
|
27
|
-
|
28
|
-
# The backtrace from the given exception or hash.
|
29
|
-
attr_reader :backtrace
|
30
|
-
|
31
|
-
# The name of the class of error (such as RuntimeError)
|
32
|
-
attr_reader :error_class
|
33
|
-
|
34
|
-
# The name of the server environment (such as "production")
|
35
|
-
attr_reader :environment_name
|
36
|
-
|
37
|
-
# CGI variables such as HTTP_METHOD
|
38
|
-
attr_reader :cgi_data
|
39
|
-
|
40
|
-
# The message from the exception, or a general description of the error
|
41
|
-
attr_reader :error_message
|
42
|
-
|
43
|
-
# See Configuration#backtrace_filters
|
44
|
-
attr_reader :backtrace_filters
|
45
|
-
|
46
|
-
# See Configuration#params_filters
|
47
|
-
attr_reader :params_filters
|
48
|
-
|
49
|
-
# A hash of parameters from the query string or post body.
|
50
|
-
attr_reader :parameters
|
51
|
-
alias_method :params, :parameters
|
52
|
-
|
53
|
-
# The component (if any) which was used in this request (usually the controller)
|
54
|
-
attr_reader :component
|
55
|
-
alias_method :controller, :component
|
56
|
-
|
57
|
-
# The action (if any) that was called in this request
|
58
|
-
attr_reader :action
|
59
|
-
|
60
|
-
# A hash of session data from the request
|
61
|
-
attr_reader :session_data
|
62
|
-
|
63
|
-
# The path to the project that caused the error (usually Rails.root)
|
64
|
-
attr_reader :project_root
|
65
|
-
|
66
|
-
# The URL at which the error occurred (if any)
|
67
|
-
attr_reader :url
|
68
|
-
|
69
|
-
# See Configuration#ignore
|
70
|
-
attr_reader :ignore
|
71
|
-
|
72
|
-
# See Configuration#ignore_by_filters
|
73
|
-
attr_reader :ignore_by_filters
|
74
|
-
|
75
|
-
# The name of the notifier library sending this notice, such as "Airbrake Notifier"
|
76
|
-
attr_reader :notifier_name
|
77
|
-
|
78
|
-
# The version number of the notifier library sending this notice, such as "2.1.3"
|
79
|
-
attr_reader :notifier_version
|
80
|
-
|
81
|
-
# A URL for more information about the notifier library sending this notice
|
82
|
-
attr_reader :notifier_url
|
83
|
-
|
84
|
-
# The host name where this error occurred (if any)
|
85
|
-
attr_reader :hostname
|
86
|
-
|
87
|
-
# Details about the user who experienced the error
|
88
|
-
attr_reader :user
|
89
|
-
|
90
|
-
private
|
91
|
-
|
92
|
-
# Private writers for all the attributes
|
93
|
-
attr_writer :exception, :api_key, :backtrace, :error_class, :error_message,
|
94
|
-
:backtrace_filters, :parameters, :params_filters,
|
95
|
-
:session_data, :project_root, :url, :ignore,
|
96
|
-
:ignore_by_filters, :notifier_name, :notifier_url, :notifier_version,
|
97
|
-
:component, :action, :cgi_data, :environment_name, :hostname, :user
|
98
|
-
|
99
|
-
# Arguments given in the initializer
|
100
|
-
attr_accessor :args
|
101
|
-
|
102
|
-
public
|
103
|
-
|
104
|
-
def initialize(args)
|
105
|
-
self.args = args
|
106
|
-
self.exception = args[:exception]
|
107
|
-
self.api_key = args[:api_key]
|
108
|
-
self.project_root = args[:project_root]
|
109
|
-
self.url = args[:url] || rack_env(:url)
|
110
|
-
|
111
|
-
self.notifier_name = args[:notifier_name]
|
112
|
-
self.notifier_version = args[:notifier_version]
|
113
|
-
self.notifier_url = args[:notifier_url]
|
114
|
-
|
115
|
-
self.ignore = args[:ignore] || []
|
116
|
-
self.ignore_by_filters = args[:ignore_by_filters] || []
|
117
|
-
self.backtrace_filters = args[:backtrace_filters] || []
|
118
|
-
self.params_filters = args[:params_filters] || []
|
119
|
-
self.parameters = args[:parameters] ||
|
120
|
-
action_dispatch_params ||
|
121
|
-
rack_env(:params) ||
|
122
|
-
{}
|
123
|
-
self.component = args[:component] || args[:controller] || parameters['controller']
|
124
|
-
self.action = args[:action] || parameters['action']
|
125
|
-
|
126
|
-
self.environment_name = args[:environment_name]
|
127
|
-
self.cgi_data = args[:cgi_data] || args[:rack_env]
|
128
|
-
self.backtrace = Backtrace.parse(exception_attribute(:backtrace, caller), :filters => self.backtrace_filters)
|
129
|
-
self.error_class = exception_attribute(:error_class) {|exception| exception.class.name }
|
130
|
-
self.error_message = exception_attribute(:error_message, 'Notification') do |exception|
|
131
|
-
"#{exception.class.name}: #{args[:error_message] || exception.message}"
|
132
|
-
end
|
133
|
-
|
134
|
-
self.hostname = local_hostname
|
135
|
-
self.user = args[:user]
|
136
|
-
|
137
|
-
also_use_rack_params_filters
|
138
|
-
find_session_data
|
139
|
-
clean_params
|
140
|
-
clean_rack_request_data
|
141
|
-
end
|
142
|
-
|
143
|
-
# Converts the given notice to XML
|
144
|
-
def to_xml
|
145
|
-
builder = Builder::XmlMarkup.new
|
146
|
-
builder.instruct!
|
147
|
-
xml = builder.notice(:version => Airbrake::API_VERSION) do |notice|
|
148
|
-
notice.tag!("api-key", api_key)
|
149
|
-
notice.notifier do |notifier|
|
150
|
-
notifier.name(notifier_name)
|
151
|
-
notifier.version(notifier_version)
|
152
|
-
notifier.url(notifier_url)
|
153
|
-
end
|
154
|
-
notice.error do |error|
|
155
|
-
error.tag!('class', error_class)
|
156
|
-
error.message(error_message)
|
157
|
-
error.backtrace do |backtrace|
|
158
|
-
self.backtrace.lines.each do |line|
|
159
|
-
backtrace.line(:number => line.number,
|
160
|
-
:file => line.file,
|
161
|
-
:method => line.method)
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
165
|
-
if url ||
|
166
|
-
controller ||
|
167
|
-
action ||
|
168
|
-
!parameters.blank? ||
|
169
|
-
!cgi_data.blank? ||
|
170
|
-
!session_data.blank?
|
171
|
-
notice.request do |request|
|
172
|
-
request.url(url)
|
173
|
-
request.component(controller)
|
174
|
-
request.action(action)
|
175
|
-
unless parameters.nil? || parameters.empty?
|
176
|
-
request.params do |params|
|
177
|
-
xml_vars_for(params, parameters)
|
178
|
-
end
|
179
|
-
end
|
180
|
-
unless session_data.nil? || session_data.empty?
|
181
|
-
request.session do |session|
|
182
|
-
xml_vars_for(session, session_data)
|
183
|
-
end
|
184
|
-
end
|
185
|
-
unless cgi_data.nil? || cgi_data.empty?
|
186
|
-
request.tag!("cgi-data") do |cgi_datum|
|
187
|
-
xml_vars_for(cgi_datum, cgi_data)
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
191
|
-
end
|
192
|
-
notice.tag!("server-environment") do |env|
|
193
|
-
env.tag!("project-root", project_root)
|
194
|
-
env.tag!("environment-name", environment_name)
|
195
|
-
env.tag!("hostname", hostname)
|
196
|
-
end
|
197
|
-
unless user.blank?
|
198
|
-
notice.tag!("current-user") do |u|
|
199
|
-
u.tag!("id",user[:id])
|
200
|
-
u.tag!("name",user[:name])
|
201
|
-
u.tag!("email",user[:email])
|
202
|
-
u.tag!("username",user[:username])
|
203
|
-
end
|
204
|
-
end
|
205
|
-
end
|
206
|
-
xml.to_s
|
207
|
-
end
|
208
|
-
|
209
|
-
# Determines if this notice should be ignored
|
210
|
-
def ignore?
|
211
|
-
ignored_class_names.include?(error_class) ||
|
212
|
-
ignore_by_filters.any? {|filter| filter.call(self) }
|
213
|
-
end
|
214
|
-
|
215
|
-
# Allows properties to be accessed using a hash-like syntax
|
216
|
-
#
|
217
|
-
# @example
|
218
|
-
# notice[:error_message]
|
219
|
-
# @param [String] method The given key for an attribute
|
220
|
-
# @return The attribute value, or self if given +:request+
|
221
|
-
def [](method)
|
222
|
-
case method
|
223
|
-
when :request
|
224
|
-
self
|
225
|
-
else
|
226
|
-
send(method)
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
private
|
231
|
-
|
232
|
-
|
233
|
-
# Gets a property named +attribute+ of an exception, either from an actual
|
234
|
-
# exception or a hash.
|
235
|
-
#
|
236
|
-
# If an exception is available, #from_exception will be used. Otherwise,
|
237
|
-
# a key named +attribute+ will be used from the #args.
|
238
|
-
#
|
239
|
-
# If no exception or hash key is available, +default+ will be used.
|
240
|
-
def exception_attribute(attribute, default = nil, &block)
|
241
|
-
(exception && from_exception(attribute, &block)) || args[attribute] || default
|
242
|
-
end
|
243
|
-
|
244
|
-
# Gets a property named +attribute+ from an exception.
|
245
|
-
#
|
246
|
-
# If a block is given, it will be used when getting the property from an
|
247
|
-
# exception. The block should accept and exception and return the value for
|
248
|
-
# the property.
|
249
|
-
#
|
250
|
-
# If no block is given, a method with the same name as +attribute+ will be
|
251
|
-
# invoked for the value.
|
252
|
-
def from_exception(attribute)
|
253
|
-
if block_given?
|
254
|
-
yield(exception)
|
255
|
-
else
|
256
|
-
exception.send(attribute)
|
257
|
-
end
|
258
|
-
end
|
259
|
-
|
260
|
-
# Removes non-serializable data from the given attribute.
|
261
|
-
# See #clean_unserializable_data
|
262
|
-
def clean_unserializable_data_from(attribute)
|
263
|
-
self.send(:"#{attribute}=", clean_unserializable_data(send(attribute)))
|
264
|
-
end
|
265
|
-
|
266
|
-
# Removes non-serializable data. Allowed data types are strings, arrays,
|
267
|
-
# and hashes. All other types are converted to strings.
|
268
|
-
# TODO: move this onto Hash
|
269
|
-
def clean_unserializable_data(data, stack = [])
|
270
|
-
return "[possible infinite recursion halted]" if stack.any?{|item| item == data.object_id }
|
271
|
-
|
272
|
-
if data.respond_to?(:to_hash)
|
273
|
-
data.to_hash.inject({}) do |result, (key, value)|
|
274
|
-
result.merge(key => clean_unserializable_data(value, stack + [data.object_id]))
|
275
|
-
end
|
276
|
-
elsif data.respond_to?(:to_ary)
|
277
|
-
data.to_ary.collect do |value|
|
278
|
-
clean_unserializable_data(value, stack + [data.object_id])
|
279
|
-
end
|
280
|
-
else
|
281
|
-
data.to_s
|
282
|
-
end
|
283
|
-
end
|
284
|
-
|
285
|
-
# Replaces the contents of params that match params_filters.
|
286
|
-
# TODO: extract this to a different class
|
287
|
-
def clean_params
|
288
|
-
clean_unserializable_data_from(:parameters)
|
289
|
-
filter(parameters)
|
290
|
-
if cgi_data
|
291
|
-
clean_unserializable_data_from(:cgi_data)
|
292
|
-
filter(cgi_data)
|
293
|
-
end
|
294
|
-
if session_data
|
295
|
-
clean_unserializable_data_from(:session_data)
|
296
|
-
filter(session_data)
|
297
|
-
end
|
298
|
-
end
|
299
|
-
|
300
|
-
def clean_rack_request_data
|
301
|
-
if cgi_data
|
302
|
-
cgi_data.delete("rack.request.form_vars")
|
303
|
-
end
|
304
|
-
end
|
305
|
-
|
306
|
-
def filter(hash)
|
307
|
-
if params_filters
|
308
|
-
hash.each do |key, value|
|
309
|
-
if filter_key?(key)
|
310
|
-
hash[key] = "[FILTERED]"
|
311
|
-
elsif value.respond_to?(:to_hash)
|
312
|
-
filter(hash[key])
|
313
|
-
end
|
314
|
-
end
|
315
|
-
end
|
316
|
-
end
|
317
|
-
|
318
|
-
def filter_key?(key)
|
319
|
-
params_filters.any? do |filter|
|
320
|
-
key.to_s.eql?(filter.to_s)
|
321
|
-
end
|
322
|
-
end
|
323
|
-
|
324
|
-
def find_session_data
|
325
|
-
self.session_data = args[:session_data] || args[:session] || rack_session || {}
|
326
|
-
self.session_data = session_data[:data] if session_data[:data]
|
327
|
-
end
|
328
|
-
|
329
|
-
# Converts the mixed class instances and class names into just names
|
330
|
-
# TODO: move this into Configuration or another class
|
331
|
-
def ignored_class_names
|
332
|
-
ignore.collect do |string_or_class|
|
333
|
-
if string_or_class.respond_to?(:name)
|
334
|
-
string_or_class.name
|
335
|
-
else
|
336
|
-
string_or_class
|
337
|
-
end
|
338
|
-
end
|
339
|
-
end
|
340
|
-
|
341
|
-
def xml_vars_for(builder, hash)
|
342
|
-
hash.each do |key, value|
|
343
|
-
if value.respond_to?(:to_hash)
|
344
|
-
builder.var(:key => key){|b| xml_vars_for(b, value.to_hash) }
|
345
|
-
else
|
346
|
-
builder.var(value.to_s, :key => key)
|
347
|
-
end
|
348
|
-
end
|
349
|
-
end
|
350
|
-
|
351
|
-
def rack_env(method)
|
352
|
-
rack_request.send(method) if rack_request
|
353
|
-
rescue
|
354
|
-
{:message => "failed to call #{method} on Rack::Request -- #{$!.message}"}
|
355
|
-
end
|
356
|
-
|
357
|
-
def rack_request
|
358
|
-
@rack_request ||= if args[:rack_env]
|
359
|
-
::Rack::Request.new(args[:rack_env])
|
360
|
-
end
|
361
|
-
end
|
362
|
-
|
363
|
-
def action_dispatch_params
|
364
|
-
args[:rack_env]['action_dispatch.request.parameters'] if args[:rack_env]
|
365
|
-
end
|
366
|
-
|
367
|
-
def rack_session
|
368
|
-
args[:rack_env]['rack.session'] if args[:rack_env]
|
369
|
-
end
|
370
|
-
|
371
|
-
def also_use_rack_params_filters
|
372
|
-
if args[:rack_env]
|
373
|
-
@params_filters ||= []
|
374
|
-
@params_filters += rack_request.env["action_dispatch.parameter_filter"] || []
|
375
|
-
end
|
376
|
-
end
|
377
|
-
|
378
|
-
def local_hostname
|
379
|
-
Socket.gethostname
|
380
|
-
end
|
381
|
-
|
382
|
-
def to_s
|
383
|
-
content = []
|
384
|
-
self.class.attr_readers.each do |attr|
|
385
|
-
content << " #{attr}: #{send(attr)}"
|
386
|
-
end
|
387
|
-
content.join("\n")
|
388
|
-
end
|
389
|
-
end
|
390
|
-
end
|