partial_logging 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31887d2d34bf4551ddd900d6d960458be95b4002
4
- data.tar.gz: a2d700cb21c1aecf67eea39d6d7dfa602d01db3b
3
+ metadata.gz: 9cf5322b38adebb5c59d25638475d5585e6527ca
4
+ data.tar.gz: f7b966167261faf3474581707ff10e19ea6ed0b4
5
5
  SHA512:
6
- metadata.gz: 2272905ed87fb3e99575bf0a694a8f15f789b3b2fe4f2728051db7d0fa507cd58cd4d68edc010efe4661467dcfcd4e0aea994654177ce03a4044110778af1e1c
7
- data.tar.gz: 6f2409b514904dd043dbc7b7f3e9882c60df9804b24d97b02a5d9fd04fec1d1384871b09513b3ba628903db974467456dc7218ba8e0320a7314bc33bfac33e21
6
+ metadata.gz: 34a463b8d01018da19778edb5520926b5064be68c7d9d8f22ff39a5e19ff22c5ec7d93192603c8f85d88987c22ea2ca86e248f051ade0bc17aed83a4e6b0a8c8
7
+ data.tar.gz: 81438d325ccf00a52b611952fee7648c43d96519f70c2affd824ef2cf42e4c4c9ee4dfec111373b77be37d98129b94e0b28a98e65f2bc1a3a7f21cd9d1df6d3b
data/README.md CHANGED
@@ -2,9 +2,14 @@
2
2
 
3
3
  For figuring out where the heck this HTML is coming from.
4
4
 
5
+ This has been used successfully in Rails 3.2 and 4.1 applications, but as it relies on
6
+ the internal state of Rails may break at any time.
7
+
8
+ Be smart and don't use in production :)
9
+
5
10
  ## Configuration
6
11
 
7
- There is only one configuration option at the moment, and that is `log_partials`.
12
+ The most important configuration options is `log_partials`.
8
13
  This takes a block that should return true or false, which will be executed to determine whether or not to log partials.
9
14
 
10
15
  ```ruby
@@ -15,6 +20,13 @@ PartialLogging.config do |config|
15
20
  config.log_partials do
16
21
  Rails.env.development?
17
22
  end
23
+
24
+ # Other config options:
25
+
26
+ # absolute_path: whether to show the full file system path or just
27
+ # `(app_root)/app/views/partials/_party.html.erb`
28
+ # Default: false
29
+ # config.absolute_path true
18
30
  end
19
31
  ```
20
32
 
@@ -1,5 +1,6 @@
1
1
  module PartialLogging
2
2
  class Configuration
3
+ attr_writer :absolute_path
3
4
 
4
5
  def log_partials(&block)
5
6
  @log_partials = block
@@ -8,5 +9,19 @@ module PartialLogging
8
9
  def log_partials?
9
10
  @log_partials && @log_partials.call
10
11
  end
12
+
13
+ # If true, render the absolute path to the partial,
14
+ # otherwise render '(app root)/app/views/chill/_sauce.html.erb'
15
+ def absolute_path(show_full_path=nil)
16
+ if show_full_path.nil?
17
+ @absolute_path
18
+ else
19
+ self.absolute_path = show_full_path
20
+ end
21
+ end
22
+
23
+ def absolute_path?
24
+ !!absolute_path
25
+ end
11
26
  end
12
27
  end
@@ -9,12 +9,20 @@ class PartialLogging::PartialRendererWithLogging < ActionView::PartialRenderer
9
9
  if @lookup_context.rendered_format == :html
10
10
  output_buffer = ActionView::OutputBuffer.new
11
11
  output_buffer.safe_concat """
12
- <!-- START #{identifier} -->
12
+ <!-- START #{formatted_partial_identifier(identifier)} -->
13
13
  #{content}
14
- <!-- END #{identifier} -->
14
+ <!-- END #{formatted_partial_identifier(identifier)} -->
15
15
  """
16
16
  content = output_buffer
17
17
  end
18
18
  content
19
19
  end
20
+
21
+ def formatted_partial_identifier(identifier)
22
+ if PartialLogging.config.absolute_path?
23
+ identifier
24
+ else
25
+ identifier.sub(/#{Rails.root.to_s}/, '(app root)')
26
+ end
27
+ end
20
28
  end
@@ -2,7 +2,7 @@ module PartialLogging
2
2
  class Version
3
3
  MAJOR = 0 unless defined? MAJOR
4
4
  MINOR = 1 unless defined? MINOR
5
- PATCH = 2 unless defined? PATCH
5
+ PATCH = 3 unless defined? PATCH
6
6
  PRE = nil unless defined? PRE
7
7
 
8
8
  class << self
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: partial_logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Maddox