rack-insight 0.5.7 → 0.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.5.8 / 2012-09-03 (Peter Boling)
2
+
3
+ * Bug Fixes
4
+
5
+ * working template_root for rack-insight extension libraries
6
+
1
7
  == 0.5.7 / 2012-09-03 (Peter Boling)
2
8
 
3
9
  * Bug Fixes
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rack-insight (0.5.6)
4
+ rack-insight (0.5.7)
5
5
  rack
6
6
  sqlite3 (>= 1.3.3)
7
7
  uuidtools (>= 2.1.2)
@@ -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(:low)
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}" } unless verbose(:silent)
170
+ logger.info{ "Matched #{mask}" } if verbose(:high)
171
171
  return true
172
172
  else
173
- logger.info{ "Matched no masks" } unless verbose(:silent)
173
+ logger.info{ "Matched no masks" } if verbose(:high)
174
174
  return false
175
175
  end
176
176
  end
@@ -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]
@@ -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
- return Thread::current['rack-panel_file'] ||
46
- begin
47
- file_name = nil
48
- matched_line = nil
49
- caller.each do |line|
50
- # First make sure we are not matching rack-insight's own panel class, which will be in the caller stack,
51
- # and which may match some custom load path added (try adding 'rack' as a custom load path!)
52
- next if line =~ /rack-insight.*\/lib\/rack\/insight\/panel.rb:/
53
- Rack::Insight::Config.config[:panel_load_paths].each do |load_path|
54
- regex = %r{^[^:]*#{load_path}/([^:]*)\.rb:}
55
- md = regex.match line
56
- file_name = md[1] unless md.nil?
57
- matched_line = line unless file_name.nil?
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}"
@@ -1,4 +1,3 @@
1
-
2
1
  module Rack::Insight
3
2
 
4
3
  class CachePanel < Panel
@@ -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;
@@ -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
- templates << ::File.join(::File.join(self.class.template_root, "#{filename}.html.erb")) if self.class.respond_to?(:template_root)
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
@@ -1,7 +1,7 @@
1
1
  module Rack
2
2
  module Insight
3
3
 
4
- VERSION = '0.5.7'
4
+ VERSION = '0.5.8'
5
5
 
6
6
  end
7
7
  end
@@ -13,7 +13,8 @@
13
13
  }
14
14
 
15
15
  #rack-insight-enabler:hover {
16
- width: 50px;
16
+ width: auto;
17
+ padding:5px;
17
18
  height: 24px;
18
19
  }
19
20
  </style>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-insight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7
4
+ version: 0.5.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: