rails_view_annotator 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
data/Readme.md
CHANGED
@@ -17,9 +17,9 @@ end
|
|
17
17
|
Now rendered content will have instructive comments.
|
18
18
|
|
19
19
|
````html
|
20
|
-
<!-- begin: app/views/user/_bio.html.haml -->
|
20
|
+
<!-- begin: app/views/user/_bio.html.haml (from app/views/layouts/user/show.html.haml:4) -->
|
21
21
|
<div class='bio'>Ed's Bio</div>
|
22
|
-
<!-- end: app/views/user/_bio.html.haml -->
|
22
|
+
<!-- end: app/views/user/_bio.html.haml (from app/views/layouts/user/show.html.haml:4) -->
|
23
23
|
````
|
24
24
|
|
25
25
|
## License
|
@@ -1,11 +1,28 @@
|
|
1
1
|
module RailsViewAnnotator
|
2
|
+
class ContextError < StandardError
|
3
|
+
end
|
4
|
+
|
2
5
|
def self.augment_partial_renderer klass
|
3
6
|
render = klass.instance_method :render
|
4
7
|
klass.send(:define_method, :render) do |*args|
|
5
8
|
inner = render.bind(self).call(*args)
|
6
9
|
short_identifier = Pathname.new(identifier).relative_path_from Rails.root
|
7
|
-
|
8
|
-
|
10
|
+
|
11
|
+
backtrace = nil
|
12
|
+
begin
|
13
|
+
raise ContextError
|
14
|
+
rescue ContextError => e
|
15
|
+
backtrace = e.backtrace
|
16
|
+
end
|
17
|
+
|
18
|
+
r = /^#{Regexp.escape(Rails.root.to_s)}\/([^:]+:\d+)/
|
19
|
+
backtrace.find { |line| line.match r }
|
20
|
+
called_from = context = $1
|
21
|
+
|
22
|
+
descriptor = "#{short_identifier} (from #{called_from})"
|
23
|
+
|
24
|
+
if not inner.blank?
|
25
|
+
"<!-- begin: #{descriptor} -->\n#{inner}<!-- end: #{descriptor} -->".html_safe
|
9
26
|
end
|
10
27
|
end
|
11
28
|
klass.send(:include, InstanceMethods)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_view_annotator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-28 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: The Rails View Annotator makes it easy to find out which partial generated
|
15
15
|
which output
|