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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44620268997d5e65befca4180c45dc73b0ecf46d5fbbd1fc38862c595d6e3f23
4
- data.tar.gz: 1a79c921115393d0907578ac97798e14de5fa65ac440e540c8c70723f1c0bbba
3
+ metadata.gz: 80eb048a1dff74ccee030287645cc8996e1a338769a951c1eb5531b21fe52cb1
4
+ data.tar.gz: 96dc49e08d2dafebe2fc5863c4dd19eec5bde80578f8233c6d58b06d7c186f81
5
5
  SHA512:
6
- metadata.gz: 50113476bc070b1392cf90839ea872f59e423cf0945b4d983b1e83c7b2cbe4336e0480dbe97028f8e3eeb3994409690fb3fb842d28c015dc513a716cc84ae091
7
- data.tar.gz: a2ea2e19e0d31745e9e27ff981ac46e723692f61267f570636a1fa692f9ac610599a96f33d237bd8edbf77d3b8f61809f62abe84123886b91279e5cf07a92e4e
6
+ metadata.gz: 676d9b569fa4bdef9fc3c4c41024b94ddcbae98f15bbaf6709d7b0f35361ff4f47a567806bc0afe8a1fdd8ac111e95f86fb36c6f7098a8d3b53dd51980098ee4
7
+ data.tar.gz: 560df8c020a27ba1f48aea7fc8059c87b99fe3e83985d9bd24e907557e0d1068c3fa0aad3657fda99e04fbf76084b98d12cbf80ee308280797c78c864889ab84
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "deface"
3
- s.version = "1.5.0"
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 Rails.version < "6.0.0.beta1" && view.is_a?(ActionView::CompiledTemplates)
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 Rails.version >= "6.0.0.beta1" && view.is_a?(ActionDispatch::DebugView)
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
@@ -37,6 +37,7 @@ module Deface
37
37
  # coverts { attributes into deface compatibily attributes
38
38
  def deface_attributes(attrs)
39
39
  return if attrs.nil?
40
+ return attrs if attrs.scan(/\{/).count > 1
40
41
 
41
42
  attrs.gsub! /\{|\}/, ''
42
43
 
@@ -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 Rails.version < "6.0.0.beta1"
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 Rails.version < "6.0.0.beta1"
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 Rails.version < "6.0.0.beta1"
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
@@ -42,7 +42,7 @@ RSpec.configure do |config|
42
42
  config.mock_framework = :rspec
43
43
  end
44
44
 
45
- if Rails.version < "6.0.0.beta1"
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.0
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-07-04 00:00:00.000000000 Z
11
+ date: 2019-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri