deface 1.5.0 → 1.5.1
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/deface.gemspec +1 -1
- data/lib/deface/action_view_extensions.rb +2 -2
- data/lib/deface/haml_converter.rb +1 -0
- data/lib/deface/override.rb +3 -3
- data/spec/deface/haml_converter_spec.rb +10 -0
- data/spec/deface/override_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80eb048a1dff74ccee030287645cc8996e1a338769a951c1eb5531b21fe52cb1
|
4
|
+
data.tar.gz: 96dc49e08d2dafebe2fc5863c4dd19eec5bde80578f8233c6d58b06d7c186f81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 676d9b569fa4bdef9fc3c4c41024b94ddcbae98f15bbaf6709d7b0f35361ff4f47a567806bc0afe8a1fdd8ac111e95f86fb36c6f7098a8d3b53dd51980098ee4
|
7
|
+
data.tar.gz: 560df8c020a27ba1f48aea7fc8059c87b99fe3e83985d9bd24e907557e0d1068c3fa0aad3657fda99e04fbf76084b98d12cbf80ee308280797c78c864889ab84
|
data/deface.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "deface"
|
3
|
-
s.version = "1.5.
|
3
|
+
s.version = "1.5.1"
|
4
4
|
|
5
5
|
s.authors = ["Brian D Quinn"]
|
6
6
|
s.description = "Deface is a library that allows you to customize ERB, Haml and Slim views in a Rails application without editing the underlying view."
|
@@ -28,9 +28,9 @@ ActionView::Template.class_eval do
|
|
28
28
|
#
|
29
29
|
def render(view, locals, buffer=nil, &block)
|
30
30
|
|
31
|
-
if
|
31
|
+
if Gem.loaded_specs["rails"].version < Gem::Version.new("6.0.0.beta1") && view.is_a?(ActionView::CompiledTemplates)
|
32
32
|
mod = ActionView::CompiledTemplates
|
33
|
-
elsif
|
33
|
+
elsif Gem.loaded_specs["rails"].version >= Gem::Version.new("6.0.0.beta1") && view.is_a?(ActionDispatch::DebugView)
|
34
34
|
mod = ActionDispatch::DebugView
|
35
35
|
else
|
36
36
|
mod = view.singleton_class
|
data/lib/deface/override.rb
CHANGED
@@ -214,18 +214,18 @@ module Deface
|
|
214
214
|
# check if method is compiled for the current virtual path
|
215
215
|
#
|
216
216
|
def expire_compiled_template
|
217
|
-
if
|
217
|
+
if Gem.loaded_specs["rails"].version < Gem::Version.new("6.0.0.beta1")
|
218
218
|
if compiled_method_name = ActionView::CompiledTemplates.instance_methods.detect { |name| name =~ /#{args[:virtual_path].gsub(/[^a-z_]/, '_')}/ }
|
219
219
|
#if the compiled method does not contain the current deface digest
|
220
220
|
#then remove the old method - this will allow the template to be
|
221
221
|
#recompiled the next time it is rendered (showing the latest changes)
|
222
|
-
|
222
|
+
|
223
223
|
unless compiled_method_name =~ /\A_#{self.class.digest(:virtual_path => @args[:virtual_path])}_/
|
224
224
|
ActionView::CompiledTemplates.send :remove_method, compiled_method_name
|
225
225
|
end
|
226
226
|
end
|
227
227
|
else
|
228
|
-
if compiled_method_name = ActionDispatch::DebugView.instance_methods.detect { |name| name =~ /#{args[:virtual_path].gsub(/[^a-z_]/, '_')}/ }
|
228
|
+
if compiled_method_name = ActionDispatch::DebugView.instance_methods.detect { |name| name =~ /#{args[:virtual_path].gsub(/[^a-z_]/, '_')}/ }
|
229
229
|
unless compiled_method_name =~ /\A_#{self.class.digest(:virtual_path => @args[:virtual_path])}_/
|
230
230
|
ActionDispatch::DebugView.send :remove_method, compiled_method_name
|
231
231
|
end
|
@@ -28,6 +28,16 @@ module Deface
|
|
28
28
|
expect(haml_to_erb("%p(alt='hello world')Hello World!")).to eq("<p alt='hello world'>Hello World!</p>")
|
29
29
|
end
|
30
30
|
|
31
|
+
it "should handle recursive attributes" do
|
32
|
+
expect(haml_to_erb("%div{:data => {:foo => 'bar'}}")).to eq("<div data-foo='bar'></div>")
|
33
|
+
expect(haml_to_erb("%div{:data => {:foo => { :bar => 'baz' }, :qux => 'corge'}}")).to eq("<div data-foo-bar='baz' data-qux='corge'></div>")
|
34
|
+
|
35
|
+
if RUBY_VERSION > "1.9"
|
36
|
+
expect(haml_to_erb("%div{data: {foo: 'bar'}}")).to eq("<div data-foo='bar'></div>")
|
37
|
+
expect(haml_to_erb("%div{data: {foo: { bar: 'baz' }, qux: 'corge'}}")).to eq("<div data-foo-bar='baz' data-qux='corge'></div>")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
31
41
|
it "should handle haml attributes with commas" do
|
32
42
|
expect(haml_to_erb("%meta{'http-equiv' => 'X-UA-Compatible', :content => 'IE=edge,chrome=1'}")).to eq("<meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible' />")
|
33
43
|
expect(haml_to_erb("%meta(http-equiv='X-UA-Compatible' content='IE=edge,chrome=1')")).to eq("<meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible' />")
|
@@ -561,7 +561,7 @@ module Deface
|
|
561
561
|
|
562
562
|
describe "#expire_compiled_template" do
|
563
563
|
it "should remove compiled method when method name matches virtual path but not digest" do
|
564
|
-
if
|
564
|
+
if Gem.loaded_specs["rails"].version < Gem::Version.new("6.0.0.beta1")
|
565
565
|
instance_methods_count = ActionView::CompiledTemplates.instance_methods.size
|
566
566
|
|
567
567
|
module ActionView::CompiledTemplates
|
@@ -598,7 +598,7 @@ module Deface
|
|
598
598
|
end
|
599
599
|
|
600
600
|
it "should not remove compiled method when virtual path and digest matach" do
|
601
|
-
if
|
601
|
+
if Gem.loaded_specs["rails"].version < Gem::Version.new("6.0.0.beta1")
|
602
602
|
instance_methods_count = ActionView::CompiledTemplates.instance_methods.size
|
603
603
|
|
604
604
|
module ActionView::CompiledTemplates
|
data/spec/spec_helper.rb
CHANGED
@@ -42,7 +42,7 @@ RSpec.configure do |config|
|
|
42
42
|
config.mock_framework = :rspec
|
43
43
|
end
|
44
44
|
|
45
|
-
if
|
45
|
+
if Gem.loaded_specs["rails"].version < Gem::Version.new("6.0.0.beta1")
|
46
46
|
module ActionView::CompiledTemplates
|
47
47
|
#empty module for testing purposes
|
48
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deface
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian D Quinn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|