actionview-path_hints 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/actionview/path_hints.rb +75 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3f12affb8da89398e8c82ccf60a42b9a054fe06f
|
4
|
+
data.tar.gz: 2aec4135e2accf7af938ff8c3f37dfe8028ccf43
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9f5d23af1483a72f30f400c5eecd2c970d704019e3e2b468ef2971496e97560e08b0e5df768383f1d4466da8462673b98392cb1f4acba159b0ae4a36a89d0fb0
|
7
|
+
data.tar.gz: 5b7d2f7e56d18128496a691e39d1a5f983f11d8479843db966a4a82f6e4508cdca31b51f426e15b4606b7e4a38dfb67816bd61904c4160ecbbacc41ce240d824
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module ActionView
|
2
|
+
class PathHints
|
3
|
+
CONTAINER = %w(
|
4
|
+
position:relative
|
5
|
+
border:1px\ solid\ %s
|
6
|
+
)
|
7
|
+
LABEL = %w(
|
8
|
+
font-size:9px
|
9
|
+
background:beige
|
10
|
+
position:absolute
|
11
|
+
top:0
|
12
|
+
left:0
|
13
|
+
)
|
14
|
+
def initialize(view, template)
|
15
|
+
@view = view
|
16
|
+
@template = template
|
17
|
+
end
|
18
|
+
|
19
|
+
def apply(output_buffer)
|
20
|
+
output_buffer.prepend("<div style='#{sprintf(styles(CONTAINER), cached? ? 'green' : 'red')}'>"\
|
21
|
+
"<span style='#{styles(LABEL)}'>#{@template.inspect}</span>".html_safe).concat('</div>'.html_safe)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def styles(values)
|
27
|
+
values.map { |value| "#{value}!important;" }.join
|
28
|
+
end
|
29
|
+
|
30
|
+
def cached?
|
31
|
+
rails_latest? ?
|
32
|
+
@view.view_renderer.cache_hits[@template.virtual_path] :
|
33
|
+
@view.view_renderer.lookup_context.cache
|
34
|
+
end
|
35
|
+
|
36
|
+
def rails_latest?
|
37
|
+
Gem::Version.new(Rails.version) >= Gem::Version.new('5.0.0')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
PartialRenderer.class_eval do
|
42
|
+
def render_partial
|
43
|
+
path_hints.apply(_render_partial)
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def path_hints
|
49
|
+
PathHints.new(@view, @template)
|
50
|
+
end
|
51
|
+
|
52
|
+
# If there's a way to call super instead of copypasta let me know.
|
53
|
+
# This works for both rails 4 and 5
|
54
|
+
def _render_partial
|
55
|
+
instrument(:partial) do |payload|
|
56
|
+
view, locals, block = @view, @locals, @block
|
57
|
+
object, as = @object, @variable
|
58
|
+
|
59
|
+
if !block && (layout = @options[:layout])
|
60
|
+
layout = find_template(layout.to_s, @template_keys)
|
61
|
+
end
|
62
|
+
|
63
|
+
object = locals[as] if object.nil? # Respect object when object is false
|
64
|
+
locals[as] = object if @has_object
|
65
|
+
|
66
|
+
content = @template.render(view, locals) do |*name|
|
67
|
+
view._layout_for(*name, &block)
|
68
|
+
end
|
69
|
+
|
70
|
+
content = layout.render(view, locals) { content } if layout
|
71
|
+
content
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: actionview-path_hints
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.13
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Tulino
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-04-28 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Path hints for partials
|
14
|
+
email: rtulino@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/actionview/path_hints.rb
|
20
|
+
homepage: http://rubygems.org/gems/actionview-path_hints
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.6.11
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Path hints
|
44
|
+
test_files: []
|