deface 1.3.2 → 1.4.0

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
- SHA1:
3
- metadata.gz: 20078b241079df4972992b3d1129455d67cc007c
4
- data.tar.gz: 46cfa2aca3e676a22139214d5eed1e8acb9e6e7b
2
+ SHA256:
3
+ metadata.gz: 45c7cd1e4905de8fa0fda34bb4c1bed199d1b7b3544417da3caf6470624150d3
4
+ data.tar.gz: 0f9750691bc12ff9b1f140c4b9406f7d8b88148151c664205a9abf734925981d
5
5
  SHA512:
6
- metadata.gz: d894ce9d5363da8fdd94a30131b56961e47255318a1c601408db4ea8d7bcf3c29ebd1c5de79ce6a415250ae9fd912d038b552fcade7d275fe83bcc5134762be8
7
- data.tar.gz: 6ae94b0e05669891ca7b0a377003ae376cd39abceab96e5778f2874ddf1f85358355875bb693edc3b81b1fed0cb1d70097682e12d508bd63d467dc3cbcaaba7e
6
+ metadata.gz: ac8f3a409db476df004e1665ae1583f5d6aa8e4a16d2d6a9a562511efc27c902b573f1557abc101566878f8b20013b3d316082d4ad61c5af7ec2229e0d0c8a44
7
+ data.tar.gz: 630f4f01132534f6fe7c5807b5615b91a54f9e5f19952a53bf10ab75418bcdf6cb79c82c275291a7d8782ba2623293da9b9bdf777d4d8614919e1e94a15d0ec5
@@ -1,4 +1,9 @@
1
1
  script: "bundle exec rake"
2
+
3
+ before_install:
4
+ - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
5
+ - gem install bundler -v '< 2'
6
+
2
7
  rvm:
3
8
  - 2.3.7
4
9
  - 2.4.4
@@ -8,7 +13,15 @@ gemfile:
8
13
  - gemfiles/rails_5.0.gemfile
9
14
  - gemfiles/rails_5.1.gemfile
10
15
  - gemfiles/rails_5.2.gemfile
16
+ - gemfiles/rails_6.0.gemfile
11
17
  notifications:
12
18
  email:
13
19
  - brian@spreecommerce.com
14
20
  - ryan@spreecommerce.com
21
+
22
+ matrix:
23
+ exclude:
24
+ - rvm: 2.3.7
25
+ gemfile: gemfiles/rails_6.0.gemfile
26
+ - rvm: 2.4.4
27
+ gemfile: gemfiles/rails_6.0.gemfile
data/Appraisals CHANGED
@@ -13,3 +13,7 @@ end
13
13
  appraise 'rails-5.2' do
14
14
  gem 'rails', '~> 5.2.0'
15
15
  end
16
+
17
+ appraise 'rails-6.0' do
18
+ gem 'rails', '~> 6.0.0.beta3'
19
+ end
@@ -203,12 +203,13 @@ Deface scopes overrides by virtual_path (or partial / template file), that means
203
203
 
204
204
  ### Redefining Overrides
205
205
 
206
- You can redefine an existing override by simply declaring a new override with the same <tt>:virtual_path</tt> and <tt>:name</tt> that was originally used.
206
+ You can redefine an existing override by simply declaring a new override with the same <tt>:virtual_path</tt>, <tt>:name</tt> and [action](#action) that was originally used.
207
207
  You do not need to resupply all the values originally used, just the ones you want to change:
208
208
 
209
209
  ```ruby
210
210
  Deface::Override.new(:virtual_path => 'posts/index',
211
211
  :name => 'add_attrs_to_a_link',
212
+ :set_attributes => 'a#link',
212
213
  :disabled => true)
213
214
  ```
214
215
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "deface"
3
- s.version = "1.3.2"
3
+ s.version = "1.4.0"
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."
@@ -0,0 +1,13 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 6.0.0.beta3"
6
+
7
+ group :test do
8
+ gem "test-unit"
9
+ gem "pry"
10
+ gem "pry-byebug"
11
+ end
12
+
13
+ gemspec path: "../"
@@ -6,16 +6,16 @@ ActionView::Template.class_eval do
6
6
 
7
7
  if Rails.application.config.deface.enabled && should_be_defaced?(syntax)
8
8
 
9
- processed_source = Deface::Override.apply(source, details, true, syntax)
9
+ processed_source = Deface::Override.apply(source.to_param, details, true, syntax)
10
10
 
11
11
  # force change in handler before continuing to original Rails method
12
12
  # as we've just converted some other template language into ERB!
13
13
  #
14
- if [:slim, :haml].include?(syntax) && processed_source != source
14
+ if [:slim, :haml].include?(syntax) && processed_source != source.to_param
15
15
  handler = ActionView::Template::Handlers::ERB
16
16
  end
17
17
  else
18
- processed_source = source
18
+ processed_source = source.to_param
19
19
  end
20
20
 
21
21
  initialize_without_deface(processed_source, identifier, handler, details)
@@ -28,8 +28,8 @@ ActionView::Template.class_eval do
28
28
  #
29
29
  def render(view, locals, buffer=nil, &block)
30
30
 
31
- if view.is_a?(ActionView::CompiledTemplates)
32
- mod = ActionView::CompiledTemplates
31
+ if view.is_a?(ActionView::Base)
32
+ mod = ActionView::Base
33
33
  else
34
34
  mod = view.singleton_class
35
35
  end
@@ -14,9 +14,9 @@ module Deface
14
14
  case syntax
15
15
  when :haml
16
16
  #convert haml to erb before parsing before
17
- source = Deface::HamlConverter.new(source).result
17
+ source = Deface::HamlConverter.new(source.to_param).result
18
18
  when :slim
19
- source = Deface::SlimConverter.new(source).result
19
+ source = Deface::SlimConverter.new(source.to_param).result
20
20
  end
21
21
 
22
22
  doc = Deface::Parser.convert(source)
@@ -214,13 +214,13 @@ module Deface
214
214
  # check if method is compiled for the current virtual path
215
215
  #
216
216
  def expire_compiled_template
217
- if compiled_method_name = ActionView::CompiledTemplates.instance_methods.detect { |name| name =~ /#{args[:virtual_path].gsub(/[^a-z_]/, '_')}/ }
217
+ if compiled_method_name = ActionView::Base.instance_methods.detect { |name| name =~ /#{args[:virtual_path].gsub(/[^a-z_]/, '_')}/ }
218
218
  #if the compiled method does not contain the current deface digest
219
219
  #then remove the old method - this will allow the template to be
220
220
  #recompiled the next time it is rendered (showing the latest changes)
221
221
 
222
222
  unless compiled_method_name =~ /\A_#{self.class.digest(:virtual_path => @args[:virtual_path])}_/
223
- ActionView::CompiledTemplates.send :remove_method, compiled_method_name
223
+ ActionView::Base.send :remove_method, compiled_method_name
224
224
  end
225
225
  end
226
226
 
@@ -90,7 +90,11 @@ module Deface
90
90
 
91
91
  # Tag the source with the default external encoding
92
92
  # or the encoding specified in the file
93
- source.force_encoding(encoding)
93
+ if source.frozen?
94
+ source = source.dup.force_encoding(encoding)
95
+ else
96
+ source.force_encoding(encoding)
97
+ end
94
98
 
95
99
  unless source.valid_encoding?
96
100
  raise ActionView::WrongEncodingError.new(source, encoding)
@@ -560,16 +560,10 @@ module Deface
560
560
  end
561
561
 
562
562
  describe "#expire_compiled_template" do
563
- before do
564
- @compiled_templates = ActionView::CompiledTemplates
565
-
566
- ActionView::CompiledTemplates.instance_methods.each do |method_name|
567
- ActionView::CompiledTemplates.send :remove_method, method_name
568
- end
569
- end
570
-
571
563
  it "should remove compiled method when method name matches virtual path but not digest" do
572
- module ActionView::CompiledTemplates
564
+ instance_methods_count = ActionView::Base.instance_methods.size
565
+
566
+ ActionView::Base.class_eval do
573
567
  def _e235fa404c3c2281d4f6791162b1c638_posts_index_123123123
574
568
  true #not a real method
575
569
  end
@@ -577,17 +571,17 @@ module Deface
577
571
  def _f34556de606cec51d4f6791163fab456_posts_edit_123123123
578
572
  true #not a real method
579
573
  end
580
-
581
574
  end
582
575
 
583
- expect(ActionView::CompiledTemplates.instance_methods.size).to eq(2)
576
+ expect(ActionView::Base.instance_methods.size).to eq(instance_methods_count + 2)
584
577
  @override.send(:expire_compiled_template)
585
- expect(ActionView::CompiledTemplates.instance_methods.size).to eq(1)
578
+ expect(ActionView::Base.instance_methods.size).to eq(instance_methods_count + 1)
586
579
  end
587
580
 
588
581
  it "should not remove compiled method when virtual path and digest matach" do
582
+ instance_methods_count = ActionView::Base.instance_methods.size
589
583
 
590
- module ActionView::CompiledTemplates
584
+ ActionView::Base.class_eval do
591
585
  def _e235fa404c3c2281d4f6791162b1c638_posts_index_123123123
592
586
  true #not a real method
593
587
  end
@@ -595,9 +589,9 @@ module Deface
595
589
 
596
590
  expect(Deface::Override).to receive(:digest).and_return('e235fa404c3c2281d4f6791162b1c638')
597
591
 
598
- expect(ActionView::CompiledTemplates.instance_methods.size).to eq(1)
592
+ expect(ActionView::Base.instance_methods.size).to eq(instance_methods_count + 1)
599
593
  @override.send(:expire_compiled_template)
600
- expect(ActionView::CompiledTemplates.instance_methods.size).to eq(1)
594
+ expect(ActionView::Base.instance_methods.size).to eq(instance_methods_count + 1)
601
595
  end
602
596
  end
603
597
 
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
-
2
+
3
3
  require 'spec_helper'
4
4
 
5
5
  module Deface
@@ -11,6 +11,7 @@ module Deface
11
11
  expect(Deface::Parser.convert("<h1>Hello</h1>").to_s).to eq("<h1>Hello</h1>")
12
12
  expect(Deface::Parser.convert("<title>Hello</title>")).to be_an_instance_of(Nokogiri::HTML::DocumentFragment)
13
13
  expect(Deface::Parser.convert("<title>Hello</title>").to_s).to eq("<title>Hello</title>")
14
+ expect(Deface::Parser.convert("<title>Hello Frozen</title>".freeze).to_s).to eq("<title>Hello Frozen</title>")
14
15
  end
15
16
 
16
17
  it "should parse html document" do
@@ -42,10 +42,6 @@ RSpec.configure do |config|
42
42
  config.mock_framework = :rspec
43
43
  end
44
44
 
45
- module ActionView::CompiledTemplates
46
- #empty module for testing purposes
47
- end
48
-
49
45
  shared_context "mock Rails" do
50
46
  before(:each) do
51
47
  rails_version = Rails::VERSION::STRING
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.3.2
4
+ version: 1.4.0
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: 2018-10-01 00:00:00.000000000 Z
11
+ date: 2019-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -193,6 +193,7 @@ files:
193
193
  - gemfiles/rails_5.0.gemfile
194
194
  - gemfiles/rails_5.1.gemfile
195
195
  - gemfiles/rails_5.2.gemfile
196
+ - gemfiles/rails_6.0.gemfile
196
197
  - init.rb
197
198
  - lib/deface.rb
198
199
  - lib/deface/action_view_extensions.rb
@@ -304,8 +305,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
304
305
  - !ruby/object:Gem::Version
305
306
  version: '0'
306
307
  requirements: []
307
- rubyforge_project:
308
- rubygems_version: 2.6.10
308
+ rubygems_version: 3.0.2
309
309
  signing_key:
310
310
  specification_version: 4
311
311
  summary: Deface is a library that allows you to customize ERB, Haml and Slim views