deface 1.6.0 → 1.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Rakefile +5 -1
- data/bin/sandbox +2 -0
- data/bin/sandbox-setup +87 -22
- data/deface.gemspec +1 -0
- data/gemfiles/rails_6.1.gemfile +13 -0
- data/lib/deface/action_view_extensions.rb +40 -30
- data/lib/deface/applicator.rb +49 -37
- data/lib/deface/template_helper.rb +42 -16
- data/lib/deface/version.rb +5 -1
- data/spec/deface/action_view_template_spec.rb +50 -43
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13f8d0d00b60a47809b55b1c260da178bf2ab6c4087a73b154b1d4e2abe4e51a
|
4
|
+
data.tar.gz: 44b725c4108968143fb985c15ce297666076b7093b29c97d0cf4f546ac5a9f23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24e344680c4d7a72b1e1e10c8dc1c1e60bf2fb8234037ca95f361b67827307f6e3f4fd932168aa0c559d2015387b442cc0eee349cc792eeaa4f4970907cc7037
|
7
|
+
data.tar.gz: ae4600922bdd43fbfc3db5fec9f75bfa33bef4bca005130f6f13824deec82e1bfb1a9152c53eaf2893e36406e430c27c0487e79618d37719db1dcc3d9dc07f07
|
data/.gitignore
CHANGED
data/Rakefile
CHANGED
@@ -5,8 +5,12 @@ require 'rdoc/task'
|
|
5
5
|
require 'rspec'
|
6
6
|
require 'rspec/core/rake_task'
|
7
7
|
|
8
|
+
require 'bundler'
|
9
|
+
Bundler.require
|
10
|
+
Bundler::GemHelper.install_tasks
|
11
|
+
|
8
12
|
desc 'Default: run specs'
|
9
|
-
task :default => :spec
|
13
|
+
task :default => :spec
|
10
14
|
RSpec::Core::RakeTask.new do |t|
|
11
15
|
t.pattern = "spec/**/*_spec.rb"
|
12
16
|
end
|
data/bin/sandbox
CHANGED
data/bin/sandbox-setup
CHANGED
@@ -1,24 +1,89 @@
|
|
1
|
-
#!/usr/bin/env
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
extend FileUtils
|
5
|
+
|
6
|
+
system 'bin/rails g scaffold Post title body'
|
7
|
+
system 'bin/rails db:migrate'
|
8
|
+
|
9
|
+
mkdir_p 'sandbox/app/overrides'
|
10
|
+
|
11
|
+
File.write 'sandbox/app/views/posts/_haml_partial.html.haml', <<~HAML
|
12
|
+
%h2 hello from haml
|
13
|
+
HAML
|
14
|
+
|
15
|
+
File.write 'sandbox/app/views/posts/_slim_partial.html.slim', <<~SLIM
|
16
|
+
h2 hello from slim
|
17
|
+
SLIM
|
18
|
+
|
19
|
+
File.write 'sandbox/app/views/posts/_haml_defaced_partial.html.haml', <<~HAML
|
20
|
+
%h3 hello from defaced haml
|
21
|
+
HAML
|
22
|
+
|
23
|
+
File.write 'sandbox/app/views/posts/_slim_defaced_partial.html.slim', <<~SLIM
|
24
|
+
h3 hello from defaced slim
|
25
|
+
SLIM
|
26
|
+
|
27
|
+
File.write 'sandbox/app/overrides/improved_posts.rb', <<~RUBY
|
28
|
+
Deface::Override.new(
|
29
|
+
virtual_path: "posts/show",
|
30
|
+
name: "sparkling_post_title",
|
31
|
+
replace: 'p:nth-child(2)',
|
32
|
+
text: "<h1>✨<%= @post.title %>✨</h1>"
|
33
|
+
)
|
34
|
+
|
35
|
+
Deface::Override.new(
|
36
|
+
virtual_path: "posts/show",
|
37
|
+
name: "modern_style_post_body",
|
38
|
+
replace: 'p:nth-child(3)',
|
39
|
+
text: "<p style='border:2px gray solid; padding: 1rem;'><%= @post.body %></p>"
|
40
|
+
)
|
41
|
+
|
42
|
+
Deface::Override.new(
|
43
|
+
virtual_path: "posts/index",
|
44
|
+
name: "sparkling_posts_title",
|
45
|
+
replace: 'tr td:first-child',
|
46
|
+
text: "<td>✨<%= post.title %>✨</td>"
|
47
|
+
)
|
48
|
+
|
49
|
+
Deface::Override.new(
|
50
|
+
virtual_path: "posts/index",
|
51
|
+
name: "modern_style_post_body",
|
52
|
+
replace: 'tr td:nth-child(2)',
|
53
|
+
text: "<td style='border:2px gray solid; padding: 1rem;'><%= post.body %></d>"
|
54
|
+
)
|
55
|
+
|
56
|
+
Deface::Override.new(
|
57
|
+
virtual_path: "posts/index",
|
58
|
+
name: "haml_and_slim_partials",
|
59
|
+
insert_before: 'table',
|
60
|
+
text: "
|
61
|
+
<header><%= render 'haml_partial' %><%= render 'slim_partial' %></header>
|
62
|
+
<section><%= render 'haml_defaced_partial' %><%= render 'slim_defaced_partial' %></section>
|
63
|
+
"
|
64
|
+
)
|
65
|
+
|
66
|
+
Deface::Override.new(
|
67
|
+
virtual_path: "posts/_haml_defaced_partial",
|
68
|
+
name: "haml_deface",
|
69
|
+
insert_before: 'h3',
|
70
|
+
text: "<h4>HAML subtitle</h4>"
|
71
|
+
)
|
72
|
+
|
73
|
+
Deface::Override.new(
|
74
|
+
virtual_path: "posts/_slim_defaced_partial",
|
75
|
+
name: "slim_deface",
|
76
|
+
insert_before: 'h3',
|
77
|
+
text: "<h4>SLIM subtitle</h4>"
|
78
|
+
)
|
79
|
+
RUBY
|
80
|
+
|
81
|
+
File.write 'sandbox/config/routes.rb', <<~RUBY
|
82
|
+
Rails.application.routes.draw do
|
83
|
+
resources :posts
|
84
|
+
root to: "posts#index"
|
85
|
+
end
|
22
86
|
RUBY
|
23
87
|
|
24
|
-
bin/rails runner "Post.create(title: 'Foo', body: 'Bar '*10)"
|
88
|
+
system "bin/rails", "runner", "Post.create(title: 'Foo', body: 'Bar '*10)"
|
89
|
+
system "bin/rails", "runner", "Post.create(title: 'Baz', body: 'Boz '*10)"
|
data/deface.gemspec
CHANGED
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
36
|
|
37
37
|
spec.add_development_dependency('appraisal')
|
38
38
|
spec.add_development_dependency('erubis')
|
39
|
+
spec.add_development_dependency('gem-release')
|
39
40
|
spec.add_development_dependency('rspec', '>= 3.1.0')
|
40
41
|
spec.add_development_dependency('haml', ['>= 4.0', '< 6'])
|
41
42
|
spec.add_development_dependency('slim', '~> 3.0')
|
@@ -14,46 +14,56 @@ module Deface::ActionViewExtensions
|
|
14
14
|
end
|
15
15
|
|
16
16
|
module DefacedTemplate
|
17
|
-
def
|
18
|
-
|
17
|
+
def encode!
|
18
|
+
return super unless Rails.application.config.deface.enabled
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
# Before Rails 6 encode! returns nil
|
21
|
+
source = Deface.before_rails_6? ? (super; @source) : super
|
22
|
+
syntax = Deface::ActionViewExtensions.determine_syntax(@handler)
|
23
|
+
overrides = Deface::Override.find(
|
24
|
+
locals: @locals,
|
25
|
+
format: @format,
|
26
|
+
variant: @variant,
|
27
|
+
virtual_path: @virtual_path,
|
28
|
+
)
|
22
29
|
|
23
|
-
|
24
|
-
#
|
25
|
-
|
26
|
-
|
27
|
-
|
30
|
+
if syntax && overrides.any?
|
31
|
+
# Prevents any caching by rails in development mode.
|
32
|
+
@updated_at = Time.now if Deface.before_rails_6?
|
33
|
+
@handler = ActionView::Template::Handlers::ERB
|
34
|
+
|
35
|
+
# Modify the existing string instead of returning a copy
|
36
|
+
new_source = Deface::Override.apply_overrides(
|
37
|
+
Deface::Override.convert_source(source, syntax: syntax),
|
38
|
+
overrides: overrides
|
39
|
+
)
|
40
|
+
|
41
|
+
if Deface.before_rails_6?
|
42
|
+
@source.replace new_source
|
43
|
+
else
|
44
|
+
source.replace new_source
|
28
45
|
end
|
29
|
-
else
|
30
|
-
processed_source = source.to_param
|
31
46
|
end
|
32
47
|
|
33
|
-
|
48
|
+
source
|
34
49
|
end
|
35
50
|
|
36
|
-
|
37
|
-
# view needs to be recompiled
|
38
|
-
#
|
39
|
-
def render(view, locals, buffer=nil, &block)
|
40
|
-
mod = view.is_a?(Deface.template_class) ? Deface.template_class : view.singleton_class
|
51
|
+
private
|
41
52
|
|
42
|
-
|
43
|
-
|
44
|
-
@source = refresh(view).source
|
45
|
-
end
|
46
|
-
super(view, locals, buffer, &block)
|
47
|
-
end
|
53
|
+
def compile!(view)
|
54
|
+
return super unless Rails.application.config.deface.enabled
|
48
55
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
def method_name
|
53
|
-
deface_hash = Deface::Override.digest(:virtual_path => @virtual_path)
|
56
|
+
@compile_mutex.synchronize do
|
57
|
+
current_deface_hash = Deface::Override.digest(virtual_path: @virtual_path)
|
58
|
+
@deface_hash = current_deface_hash if @deface_hash.nil?
|
54
59
|
|
55
|
-
|
56
|
-
|
60
|
+
if @deface_hash != current_deface_hash
|
61
|
+
@compiled = nil
|
62
|
+
@deface_hash = current_deface_hash
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
super
|
57
67
|
end
|
58
68
|
|
59
69
|
ActionView::Template.prepend self
|
data/lib/deface/applicator.rb
CHANGED
@@ -6,58 +6,70 @@ module Deface
|
|
6
6
|
def apply(source, details, log=true, syntax=:erb)
|
7
7
|
overrides = find(details)
|
8
8
|
|
9
|
-
|
10
|
-
Rails.logger.debug "\e[1;32mDeface:\e[0m #{overrides.size} overrides found for '#{details[:virtual_path]}'"
|
11
|
-
end
|
9
|
+
return source if overrides.empty?
|
12
10
|
|
13
|
-
|
14
|
-
case syntax
|
15
|
-
when :haml
|
16
|
-
#convert haml to erb before parsing before
|
17
|
-
source = Deface::HamlConverter.new(source.to_param).result
|
18
|
-
when :slim
|
19
|
-
source = Deface::SlimConverter.new(source.to_param).result
|
20
|
-
end
|
11
|
+
Rails.logger.debug "\e[1;32mDeface:\e[0m #{overrides.size} overrides found for '#{details[:virtual_path]}'" if log
|
21
12
|
|
22
|
-
|
13
|
+
apply_overrides(
|
14
|
+
convert_source(source, syntax: syntax),
|
15
|
+
overrides: overrides,
|
16
|
+
log: log
|
17
|
+
)
|
18
|
+
end
|
23
19
|
|
24
|
-
|
25
|
-
|
26
|
-
Rails.logger.debug("\e[1;32mDeface:\e[0m '#{override.name}' is disabled") if log
|
27
|
-
next
|
28
|
-
end
|
20
|
+
# applies specified overrides to given source
|
21
|
+
def apply_overrides(source, overrides:, log: true)
|
29
22
|
|
30
|
-
|
31
|
-
matches = override.matcher.matches(doc, log)
|
23
|
+
doc = Deface::Parser.convert(source)
|
32
24
|
|
33
|
-
|
34
|
-
|
25
|
+
overrides.each do |override|
|
26
|
+
if override.disabled?
|
27
|
+
Rails.logger.debug("\e[1;32mDeface:\e[0m '#{override.name}' is disabled") if log
|
28
|
+
next
|
29
|
+
end
|
35
30
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
31
|
+
override.parsed_document = doc
|
32
|
+
matches = override.matcher.matches(doc, log)
|
33
|
+
|
34
|
+
if log
|
35
|
+
Rails.logger.send(matches.size == 0 ? :error : :debug, "\e[1;32mDeface:\e[0m '#{override.name}' matched #{matches.size} times with '#{override.selector}'")
|
42
36
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
override.
|
47
|
-
matches.each {|match| override.execute_action match }
|
37
|
+
# temporarily check and notify on use of old selector styles.
|
38
|
+
#
|
39
|
+
if matches.empty? && override.selector.match(/code|erb-loud|erb-silent/)
|
40
|
+
Rails.logger.error "\e[1;32mDeface: [WARNING]\e[0m Override '#{override.name}' may be using an invalid selector of '#{override.selector}', <code erb-loud|silent> tags are now <erb loud|silent>"
|
48
41
|
end
|
49
42
|
end
|
50
43
|
|
51
|
-
|
52
|
-
|
44
|
+
if matches.empty?
|
45
|
+
override.failure = "failed to match :#{override.action} selector '#{override.selector}'"
|
46
|
+
else
|
47
|
+
override.failure = nil
|
48
|
+
matches.each {|match| override.execute_action match }
|
49
|
+
end
|
50
|
+
end
|
53
51
|
|
54
|
-
|
52
|
+
source = doc.to_s
|
55
53
|
|
56
|
-
|
57
|
-
end
|
54
|
+
Deface::Parser.undo_erb_markup!(source)
|
58
55
|
|
59
56
|
source
|
60
57
|
end
|
58
|
+
|
59
|
+
# converts the source to a supported syntax (ERB)
|
60
|
+
def convert_source(source, syntax:)
|
61
|
+
# convert haml/slim to erb before parsing before
|
62
|
+
case syntax
|
63
|
+
when :erb
|
64
|
+
source
|
65
|
+
when :haml
|
66
|
+
Deface::HamlConverter.new(source.to_s).result
|
67
|
+
when :slim
|
68
|
+
Deface::SlimConverter.new(source.to_s).result
|
69
|
+
else
|
70
|
+
raise "unsupported syntax: #{syntax}"
|
71
|
+
end
|
72
|
+
end
|
61
73
|
end
|
62
74
|
|
63
75
|
def execute_action(target_element)
|
@@ -1,32 +1,58 @@
|
|
1
1
|
module Deface
|
2
2
|
module TemplateHelper
|
3
|
+
def self.lookup_context
|
4
|
+
@lookup_context ||= ActionView::LookupContext.new(
|
5
|
+
ActionController::Base.view_paths, {:formats => [:html]}
|
6
|
+
)
|
7
|
+
end
|
3
8
|
|
4
9
|
# used to find source for a partial or template using virtual_path
|
5
|
-
def load_template_source(virtual_path, partial, apply_overrides=true)
|
10
|
+
def load_template_source(virtual_path, partial, apply_overrides=true, lookup_context: Deface::TemplateHelper.lookup_context)
|
6
11
|
parts = virtual_path.split("/")
|
7
|
-
|
12
|
+
|
8
13
|
if parts.size == 2
|
9
|
-
prefix
|
14
|
+
prefix = ""
|
10
15
|
name = virtual_path
|
11
16
|
else
|
12
|
-
prefix
|
17
|
+
prefix = parts.shift
|
13
18
|
name = parts.join("/")
|
14
19
|
end
|
15
20
|
|
16
|
-
|
17
|
-
Rails.application.config.deface.enabled = apply_overrides
|
18
|
-
@lookup_context ||= ActionView::LookupContext.new(ActionController::Base.view_paths, {:formats => [:html]})
|
19
|
-
view = @lookup_context.disable_cache do
|
20
|
-
@lookup_context.find(name, prefix, partial)
|
21
|
-
end
|
21
|
+
view = lookup_context.disable_cache { lookup_context.find(name, [prefix], partial) }
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
source =
|
24
|
+
if view.handler.to_s == "Haml::Plugin"
|
25
|
+
Deface::HamlConverter.new(view.source).result
|
26
|
+
elsif view.handler.class.to_s == "Slim::RailsTemplate"
|
27
|
+
Deface::SlimConverter.new(view.source).result
|
28
|
+
else
|
29
|
+
view.source
|
30
|
+
end
|
31
|
+
|
32
|
+
if apply_overrides
|
33
|
+
begin
|
34
|
+
# This needs to be reviewed for production mode, overrides not present
|
35
|
+
original_enabled = Rails.application.config.deface.enabled
|
36
|
+
Rails.application.config.deface.enabled = apply_overrides
|
37
|
+
|
38
|
+
syntax = Deface::ActionViewExtensions.determine_syntax(view.handler)
|
39
|
+
overrides = Deface::Override.find(
|
40
|
+
locals: view.instance_variable_get(:@locals),
|
41
|
+
format: view.instance_variable_get(:@format),
|
42
|
+
variant: view.instance_variable_get(:@variant),
|
43
|
+
virtual_path: view.instance_variable_get(:@virtual_path),
|
44
|
+
)
|
45
|
+
|
46
|
+
if syntax && overrides.any?
|
47
|
+
source = Deface::Override.convert_source(source, syntax: syntax)
|
48
|
+
source = Deface::Override.apply_overrides(source, overrides: overrides)
|
49
|
+
end
|
50
|
+
ensure
|
51
|
+
Rails.application.config.deface.enabled = original_enabled
|
52
|
+
end
|
29
53
|
end
|
54
|
+
|
55
|
+
source
|
30
56
|
end
|
31
57
|
|
32
58
|
#gets source erb for an element
|
data/lib/deface/version.rb
CHANGED
@@ -3,8 +3,12 @@ require 'spec_helper'
|
|
3
3
|
describe Deface::ActionViewExtensions do
|
4
4
|
include_context "mock Rails.application"
|
5
5
|
|
6
|
-
before
|
7
|
-
skip "
|
6
|
+
before after_rails_6: true do
|
7
|
+
skip "This spec is targeted at Rails v6+" if Deface.before_rails_6?
|
8
|
+
end
|
9
|
+
|
10
|
+
before before_rails_6: true do
|
11
|
+
skip "This spec is targeted at Rails before v6+" unless Deface.before_rails_6?
|
8
12
|
end
|
9
13
|
|
10
14
|
let(:template) { ActionView::Template.new(
|
@@ -12,7 +16,7 @@ describe Deface::ActionViewExtensions do
|
|
12
16
|
path,
|
13
17
|
handler,
|
14
18
|
**options,
|
15
|
-
**(
|
19
|
+
**(Deface.before_rails_6? ? {updated_at: updated_at} : {})
|
16
20
|
) }
|
17
21
|
|
18
22
|
let(:source) { "<p>test</p>" }
|
@@ -26,7 +30,6 @@ describe Deface::ActionViewExtensions do
|
|
26
30
|
let(:format) { :html }
|
27
31
|
let(:virtual_path) { "posts/index" }
|
28
32
|
|
29
|
-
let(:supports_updated_at?) { Deface.before_rails_6? }
|
30
33
|
let(:updated_at) { Time.now - 600 }
|
31
34
|
|
32
35
|
describe "with no overrides defined" do
|
@@ -38,46 +41,12 @@ describe Deface::ActionViewExtensions do
|
|
38
41
|
expect(template.source).to eq("<p>test</p>")
|
39
42
|
end
|
40
43
|
|
41
|
-
it "should not change updated_at", :
|
44
|
+
it "should not change updated_at", :before_rails_6 do
|
42
45
|
expect(template.updated_at).to eq(updated_at)
|
43
46
|
end
|
44
47
|
end
|
45
48
|
|
46
|
-
describe "
|
47
|
-
let(:updated_at) { Time.now - 300 }
|
48
|
-
let(:source) { "<p>test</p><%= raw(text) %>" }
|
49
|
-
|
50
|
-
before do
|
51
|
-
Deface::Override.new(virtual_path: "posts/index", name: "Posts#index", remove: "p", text: "<h1>Argh!</h1>")
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should return modified source" do
|
55
|
-
expect(template.source).to eq("<%= raw(text) %>")
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should change updated_at", :supports_updated_at do
|
59
|
-
expect(template.updated_at).to be > updated_at
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe "#method_name" do
|
64
|
-
before do
|
65
|
-
ActionView::Template.define_method(
|
66
|
-
:method_name_without_deface,
|
67
|
-
ActionView::Template.instance_method(:method_name)
|
68
|
-
)
|
69
|
-
end
|
70
|
-
|
71
|
-
it "returns hash of overrides plus original method_name " do
|
72
|
-
deface_hash = Deface::Override.digest(virtual_path: 'posts/index')
|
73
|
-
super_method = template.method(:method_name).super_method
|
74
|
-
method_name = "_#{Digest::MD5.new.update("#{deface_hash}_#{super_method.call}").hexdigest}"
|
75
|
-
|
76
|
-
expect(template.send(:method_name)).to eq(method_name)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe "non erb or haml template" do
|
49
|
+
describe "unsupported template" do
|
81
50
|
let(:source) { "xml.post => :blah" }
|
82
51
|
let(:path) { "/some/path/to/file.erb" }
|
83
52
|
let(:handler) { ActionView::Template::Handlers::Builder }
|
@@ -130,17 +99,55 @@ describe Deface::ActionViewExtensions do
|
|
130
99
|
locals: local_assigns.keys
|
131
100
|
} }
|
132
101
|
|
133
|
-
|
102
|
+
it 'renders the template modified by deface using :replace' do
|
134
103
|
Deface::Override.new(
|
135
104
|
virtual_path: virtual_path,
|
136
105
|
name: "Posts#index",
|
137
106
|
replace: "p",
|
138
107
|
text: "<h1>Argh!</h1>"
|
139
108
|
)
|
140
|
-
}
|
141
109
|
|
142
|
-
it 'renders the template modified by deface' do
|
143
110
|
expect(template.render(view, local_assigns)).to eq(%{"<h1>Argh!</h1>some <br> text"})
|
144
111
|
end
|
112
|
+
|
113
|
+
it 'renders the template modified by deface using :remove' do
|
114
|
+
Deface::Override.new(
|
115
|
+
virtual_path: virtual_path,
|
116
|
+
name: "Posts#index",
|
117
|
+
remove: "p",
|
118
|
+
)
|
119
|
+
|
120
|
+
expect(template.render(view, local_assigns)).to eq(%{"some <br> text"})
|
121
|
+
end
|
122
|
+
|
123
|
+
context 'with a haml template' do
|
124
|
+
let(:source) { "%p test\n= raw(text)\n" }
|
125
|
+
let(:handler) { Haml::Plugin }
|
126
|
+
|
127
|
+
it 'renders the template modified by deface using :remove' do
|
128
|
+
Deface::Override.new(
|
129
|
+
virtual_path: virtual_path,
|
130
|
+
name: "Posts#index",
|
131
|
+
remove: "p",
|
132
|
+
)
|
133
|
+
|
134
|
+
expect(template.render(view, local_assigns)).to eq(%{\nsome <br> text})
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
context 'with a slim template' do
|
139
|
+
let(:source) { "p test\n= raw(text)\n" }
|
140
|
+
let(:handler) { Slim::RailsTemplate.new }
|
141
|
+
|
142
|
+
it 'renders the template modified by deface using :remove' do
|
143
|
+
Deface::Override.new(
|
144
|
+
virtual_path: virtual_path,
|
145
|
+
name: "Posts#index",
|
146
|
+
remove: "p",
|
147
|
+
)
|
148
|
+
|
149
|
+
expect(template.render(view, local_assigns)).to eq(%{\nsome <br> text\n})
|
150
|
+
end
|
151
|
+
end
|
145
152
|
end
|
146
153
|
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.
|
4
|
+
version: 1.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian D Quinn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: gem-release
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rspec
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -209,6 +223,7 @@ files:
|
|
209
223
|
- deface.gemspec
|
210
224
|
- gemfiles/rails_5.2.gemfile
|
211
225
|
- gemfiles/rails_6.0.gemfile
|
226
|
+
- gemfiles/rails_6.1.gemfile
|
212
227
|
- gemfiles/rails_6_1.gemfile
|
213
228
|
- lib/deface.rb
|
214
229
|
- lib/deface/action_view_extensions.rb
|
@@ -326,7 +341,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
326
341
|
- !ruby/object:Gem::Version
|
327
342
|
version: '0'
|
328
343
|
requirements: []
|
329
|
-
rubygems_version: 3.
|
344
|
+
rubygems_version: 3.1.4
|
330
345
|
signing_key:
|
331
346
|
specification_version: 4
|
332
347
|
summary: Deface is a library that allows you to customize ERB, Haml and Slim views
|