partial_logging 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/README.md +13 -1
- data/lib/partial_logging/configuration.rb +15 -0
- data/lib/partial_logging/partial_renderer_with_logging.rb +10 -2
- data/lib/partial_logging/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cf5322b38adebb5c59d25638475d5585e6527ca
|
4
|
+
data.tar.gz: f7b966167261faf3474581707ff10e19ea6ed0b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|