rack-insight 0.5.7 → 0.5.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/Gemfile.lock +1 -1
- data/lib/rack/insight/app.rb +3 -3
- data/lib/rack/insight/config.rb +1 -1
- data/lib/rack/insight/panel.rb +25 -19
- data/lib/rack/insight/panels/cache_panel.rb +0 -1
- data/lib/rack/insight/public/__insight__/insight.css +10 -10
- data/lib/rack/insight/render.rb +4 -24
- data/lib/rack/insight/version.rb +1 -1
- data/lib/rack/insight/views/enable-button.html.erb +2 -1
- metadata +1 -1
data/CHANGELOG
CHANGED
data/Gemfile.lock
CHANGED
data/lib/rack/insight/app.rb
CHANGED
@@ -160,17 +160,17 @@ module Rack::Insight
|
|
160
160
|
def ip_authorized?
|
161
161
|
return true unless options["rack-insight.ip_masks"]
|
162
162
|
|
163
|
-
logger.info{ "Checking #{@original_request.ip} against ip_masks" } if verbose(:
|
163
|
+
logger.info{ "Checking #{@original_request.ip} against ip_masks" } if verbose(:high)
|
164
164
|
ip = IPAddr.new(@original_request.ip)
|
165
165
|
|
166
166
|
mask = options["rack-insight.ip_masks"].find do |ip_mask|
|
167
167
|
ip_mask.include?(ip)
|
168
168
|
end
|
169
169
|
if mask
|
170
|
-
logger.info{ "Matched #{mask}" }
|
170
|
+
logger.info{ "Matched #{mask}" } if verbose(:high)
|
171
171
|
return true
|
172
172
|
else
|
173
|
-
logger.info{ "Matched no masks" }
|
173
|
+
logger.info{ "Matched no masks" } if verbose(:high)
|
174
174
|
return false
|
175
175
|
end
|
176
176
|
end
|
data/lib/rack/insight/config.rb
CHANGED
@@ -30,7 +30,7 @@ module Rack::Insight
|
|
30
30
|
@config ||= DEFAULTS
|
31
31
|
def self.configure &block
|
32
32
|
yield @config
|
33
|
-
logger.debug("Config#configure:\n called from: #{caller[0]}\n with: #{@config}")
|
33
|
+
logger.debug("Rack::Insight::Config#configure:\n called from: #{caller[0]}\n with: #{@config}") if config[:verbosity] == true || config[:verbosity].respond_to?(:<) && config[:verbosity] <= 1
|
34
34
|
@logger = config[:logger]
|
35
35
|
@log_level = config[:log_level]
|
36
36
|
@log_file = config[:log_file]
|
data/lib/rack/insight/panel.rb
CHANGED
@@ -17,6 +17,9 @@ module Rack::Insight
|
|
17
17
|
attr_reader :request
|
18
18
|
|
19
19
|
class << self
|
20
|
+
|
21
|
+
include Rack::Insight::Logging
|
22
|
+
|
20
23
|
attr_accessor :template_root
|
21
24
|
def file_index
|
22
25
|
return @file_index ||= Hash.new do |h,k|
|
@@ -41,31 +44,34 @@ module Rack::Insight
|
|
41
44
|
Thread::current['rack-panel_file'] = old_rel
|
42
45
|
end
|
43
46
|
|
47
|
+
def set_sub_class_template_root(sub_class, path)
|
48
|
+
sub_class.template_root = path
|
49
|
+
end
|
50
|
+
|
44
51
|
def current_panel_file(sub)
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
break unless file_name.nil?
|
59
|
-
end
|
60
|
-
break unless file_name.nil?
|
61
|
-
end
|
62
|
-
sub.template_root = File.dirname(matched_line.split(':')[0]) if matched_line.respond_to?(:split)
|
63
|
-
file_name
|
52
|
+
file_name = nil
|
53
|
+
matched_line = nil
|
54
|
+
caller.each do |line|
|
55
|
+
# First make sure we are not matching rack-insight's own panel class, which will be in the caller stack,
|
56
|
+
# and which may match some custom load path added (try adding 'rack' as a custom load path!)
|
57
|
+
# .*panel because the panels that ship with rack-insight also do not need custom template roots.
|
58
|
+
next if line =~ /rack-insight.*\/lib\/rack\/insight\/.*panel.rb:/
|
59
|
+
Rack::Insight::Config.config[:panel_load_paths].each do |load_path|
|
60
|
+
regex = %r{^[^:]*#{load_path}/([^:]*)\.rb:}
|
61
|
+
md = regex.match line
|
62
|
+
file_name = md[1] unless md.nil?
|
63
|
+
matched_line = line unless file_name.nil?
|
64
|
+
break unless file_name.nil?
|
64
65
|
end
|
66
|
+
break unless file_name.nil?
|
67
|
+
end
|
68
|
+
set_sub_class_template_root(sub, File.dirname(matched_line.split(':')[0])) if matched_line.respond_to?(:split)
|
69
|
+
return Thread::current['rack-panel_file'] || file_name
|
65
70
|
end
|
66
71
|
|
67
72
|
def inherited(sub)
|
68
73
|
if filename = current_panel_file(sub)
|
74
|
+
logger.debug("panel inherited by #{sub.inspect} with template_root: #{sub.template_root}") if verbose(:high)
|
69
75
|
Panel::file_index[filename] << sub
|
70
76
|
else
|
71
77
|
warn "Rack::Insight::Panel inherited by #{sub.name} outside rack-insight's :panel_load_paths. Discarded. Configured panel load paths are: #{Rack::Insight::Config.config[:panel_load_paths].inspect}"
|
@@ -22,22 +22,22 @@
|
|
22
22
|
right:0;
|
23
23
|
cursor: pointer;
|
24
24
|
}
|
25
|
-
.insight_bottom #rack-insight_toolbar {
|
25
|
+
.rack-insight_bottom #rack-insight_toolbar {
|
26
26
|
bottom:0;
|
27
27
|
border-top: 2px solid #234f32;
|
28
28
|
}
|
29
|
-
.insight_top #rack-insight_toolbar {
|
29
|
+
.rack-insight_top #rack-insight_toolbar {
|
30
30
|
top:0;
|
31
31
|
border-bottom: 2px solid #234f32;
|
32
32
|
}
|
33
33
|
|
34
|
-
.insight_error #rack-insight_toolbar {
|
34
|
+
.rack-insight_error #rack-insight_toolbar {
|
35
35
|
background: #ff0000;
|
36
36
|
color: #fff;
|
37
37
|
border: none;
|
38
38
|
}
|
39
39
|
|
40
|
-
.insight_error #rack-insight_toolbar p {
|
40
|
+
.rack-insight_error #rack-insight_toolbar p {
|
41
41
|
margin-top: 6px;
|
42
42
|
margin-left: 15px;
|
43
43
|
font-weight: bold;
|
@@ -104,11 +104,11 @@
|
|
104
104
|
overflow: auto;
|
105
105
|
}
|
106
106
|
|
107
|
-
#rack-insight.insight_top .panel_content {
|
107
|
+
#rack-insight.rack-insight_top .panel_content {
|
108
108
|
top: 32px;
|
109
109
|
}
|
110
110
|
|
111
|
-
#rack-insight.insight_bottom .panel_content {
|
111
|
+
#rack-insight.rack-insight_bottom .panel_content {
|
112
112
|
bottom: 32px;
|
113
113
|
}
|
114
114
|
|
@@ -202,10 +202,10 @@
|
|
202
202
|
margin-left: 10px;
|
203
203
|
}
|
204
204
|
|
205
|
-
#rack-insight .panel_content table tr.odd td.insight_spinner,
|
206
|
-
#rack-insight .panel_content table tr.even td.insight_spinner,
|
207
|
-
#rack-insight .panel_content table td.insight_spinner,
|
208
|
-
#rack-insight .insight_spinner {
|
205
|
+
#rack-insight .panel_content table tr.odd td.rack-insight_spinner,
|
206
|
+
#rack-insight .panel_content table tr.even td.rack-insight_spinner,
|
207
|
+
#rack-insight .panel_content table td.rack-insight_spinner,
|
208
|
+
#rack-insight .rack-insight_spinner {
|
209
209
|
background-image: url(/__insight__/spinner.gif);
|
210
210
|
background-repeat: no-repeat;
|
211
211
|
background-position: center center;
|
data/lib/rack/insight/render.rb
CHANGED
@@ -49,33 +49,13 @@ module Rack::Insight
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
#def compiled_source(filename)
|
53
|
-
# primary_file_path = ::File.join(::File.dirname(__FILE__), "views/#{filename}.html.erb")
|
54
|
-
# file = nil
|
55
|
-
# begin
|
56
|
-
# file = ::File.read(primary_file_path)
|
57
|
-
# rescue Errno::ENOENT
|
58
|
-
# end
|
59
|
-
# if file.nil?
|
60
|
-
# Rack::Insight::Config.config[:panel_load_paths].each do |load_path|
|
61
|
-
# begin
|
62
|
-
# file = ::File.read(::File.join(load_path, "#{filename}.html.erb"))
|
63
|
-
# break # If no error is raised then the file was read!
|
64
|
-
# rescue Errno::ENOENT
|
65
|
-
# end
|
66
|
-
# end
|
67
|
-
# end
|
68
|
-
# if file
|
69
|
-
# ::ERB.new(file, nil, "-").src
|
70
|
-
# else
|
71
|
-
# logger.fatal("Rack::Insight: Unable to find expected view template #{primary_file_path} or a #{filename}.html.erb template in rack-insight's :panel_load_paths. Configured panel load paths are: #{Rack::Insight::Config.config[:panel_load_paths].inspect}")
|
72
|
-
# end
|
73
|
-
#end
|
74
|
-
|
75
52
|
def compiled_source(filename)
|
76
53
|
templates = []
|
77
54
|
templates << ::File.join(::File.dirname(__FILE__), "views/#{filename}.html.erb")
|
78
|
-
|
55
|
+
if self.class.respond_to?(:template_root) && !self.class.template_root.nil?
|
56
|
+
# Push onto the front of the array to try because if there is a template root it is the most likely place to find the view.
|
57
|
+
templates.unshift(::File.join(::File.join(self.class.template_root, "#{filename}.html.erb")))
|
58
|
+
end
|
79
59
|
file = nil
|
80
60
|
templates.each do |template_path|
|
81
61
|
begin
|
data/lib/rack/insight/version.rb
CHANGED