custos_notifier 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/custos_notifier.rb +26 -2
- data/lib/custos_notifier/rack.rb +22 -1
- metadata +4 -4
data/lib/custos_notifier.rb
CHANGED
@@ -85,7 +85,7 @@ module CustosNotifier
|
|
85
85
|
@server = `hostname -s`.chomp
|
86
86
|
@source = ""
|
87
87
|
@process_id = $$
|
88
|
-
@parameters = rack_env(:params)
|
88
|
+
@parameters = rack_env(:params) || {}
|
89
89
|
@request_uri = rack_env(:url) || ""
|
90
90
|
@document_root = rack_env(:env) { |env| env["DOCUMENT_ROOT"] } || ""
|
91
91
|
@content_length = rack_env(:env) { |env| env["DOCUMENT_ROOT"] } || ""
|
@@ -120,7 +120,7 @@ module CustosNotifier
|
|
120
120
|
:process_id => @process_id,
|
121
121
|
:request => {
|
122
122
|
:uri => @request_uri,
|
123
|
-
:parameters => @parameters,
|
123
|
+
:parameters => filter(@parameters).inspect,
|
124
124
|
:document_root => @document_root,
|
125
125
|
:content_length => @content_length,
|
126
126
|
:http_accept => @http_accept,
|
@@ -170,6 +170,30 @@ module CustosNotifier
|
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
173
|
+
|
174
|
+
def filter(hash)
|
175
|
+
unless filters.empty?
|
176
|
+
hash.each do |key, value|
|
177
|
+
if filter_key?(key)
|
178
|
+
hash[key] = "[FILTERED]"
|
179
|
+
elsif value.respond_to?(:to_hash)
|
180
|
+
filter(hash[key])
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
hash
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
def filters
|
189
|
+
@filters ||= @args[:rack_env]["action_dispatch.parameter_filter"] || []
|
190
|
+
end
|
191
|
+
|
192
|
+
|
193
|
+
def filter_key?(key)
|
194
|
+
filters.any? {|filter| key.to_s.include? filter.to_s }
|
195
|
+
end
|
196
|
+
|
173
197
|
end
|
174
198
|
|
175
199
|
end
|
data/lib/custos_notifier/rack.rb
CHANGED
@@ -29,10 +29,31 @@ module CustosNotifier
|
|
29
29
|
@app.call(env)
|
30
30
|
rescue Exception => raised
|
31
31
|
CustosNotifier.notify(raised, :rack_env => env)
|
32
|
-
|
32
|
+
if rails_3_app?
|
33
|
+
if rails_3_not_dev?
|
34
|
+
[500, {"Content-Type" => "text/html"}, File.read(File.join Rails.root, "public/500.html")]
|
35
|
+
else
|
36
|
+
raise
|
37
|
+
end
|
38
|
+
else
|
39
|
+
[500, {"Content-Type" => "text/html"},"Something went wrong"]
|
40
|
+
end
|
33
41
|
end
|
34
42
|
end
|
35
43
|
|
44
|
+
|
45
|
+
protected
|
46
|
+
|
47
|
+
|
48
|
+
def rails_3_app?
|
49
|
+
defined?(Rails).nil? != true
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
def rails_3_not_dev?
|
54
|
+
!%w(development test).include?(Rails.env)
|
55
|
+
end
|
56
|
+
|
36
57
|
end
|
37
58
|
|
38
59
|
end
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: custos_notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: "0.
|
8
|
+
- 2
|
9
|
+
version: "0.2"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Sebastian Nowak
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-07-01 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|