deface 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/deface.gemspec +2 -2
- data/lib/deface.rb +5 -0
- data/lib/deface/action_view_extensions.rb +1 -1
- data/lib/deface/digest.rb +25 -0
- data/lib/deface/original_validator.rb +1 -1
- data/lib/deface/override.rb +4 -3
- data/spec/deface/digest_spec.rb +24 -0
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1abef419e3fa75dc8e8f82e92f9fdd019d1adb83
|
4
|
+
data.tar.gz: 4ca2e8f9f48cd397428398f7315bfc93634ca6a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bdc37fec62caed46381652d1a3da9f6cb20e6b366876aaea9e18f33862994122808a7c6d66e7bde35f094ed27d30c06627a05627b4d183fce697bd0b5e6f296
|
7
|
+
data.tar.gz: 6511b13a014b50fd9049314b8e6191ad99698bc571b2e564099e6de86da37840f092d1e911a1e1f60e0c4d4e9f32ebb4ea0d9b0f966f4af71539270963e28ed0
|
data/deface.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "deface"
|
3
|
-
s.version = "1.3.
|
3
|
+
s.version = "1.3.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."
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.require_paths = ["lib"]
|
16
16
|
s.summary = "Deface is a library that allows you to customize ERB, Haml and Slim views in Rails"
|
17
17
|
|
18
|
-
s.add_dependency('nokogiri', '
|
18
|
+
s.add_dependency('nokogiri', '>= 1.6')
|
19
19
|
s.add_dependency('rails', '>= 4.1')
|
20
20
|
s.add_dependency('rainbow', '>= 2.1.0')
|
21
21
|
s.add_dependency('polyglot')
|
data/lib/deface.rb
CHANGED
@@ -4,6 +4,7 @@ require "deface/template_helper"
|
|
4
4
|
require "deface/original_validator"
|
5
5
|
require "deface/applicator"
|
6
6
|
require "deface/search"
|
7
|
+
require "deface/digest"
|
7
8
|
require "deface/override"
|
8
9
|
require "deface/parser"
|
9
10
|
require "deface/dsl/loader"
|
@@ -42,6 +43,10 @@ module Deface
|
|
42
43
|
require "deface/railtie"
|
43
44
|
end
|
44
45
|
|
46
|
+
if defined?(ActiveSupport::Digest)
|
47
|
+
Deface::Digest.digest_class = ActiveSupport::Digest
|
48
|
+
end
|
49
|
+
|
45
50
|
# Exceptions
|
46
51
|
class DefaceError < StandardError; end
|
47
52
|
|
@@ -52,7 +52,7 @@ ActionView::Template.class_eval do
|
|
52
52
|
deface_hash = Deface::Override.digest(:virtual_path => @virtual_path)
|
53
53
|
|
54
54
|
#we digest the whole method name as if it gets too long there's problems
|
55
|
-
"_#{Digest
|
55
|
+
"_#{Deface::Digest.hexdigest("#{deface_hash}_#{method_name_without_deface}")}"
|
56
56
|
end
|
57
57
|
|
58
58
|
private
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Deface
|
2
|
+
class Digest
|
3
|
+
class <<self
|
4
|
+
def digest_class
|
5
|
+
@digest_class || ::Digest::MD5
|
6
|
+
end
|
7
|
+
|
8
|
+
def digest_class=(klass)
|
9
|
+
@digest_class = klass
|
10
|
+
end
|
11
|
+
|
12
|
+
def hexdigest(arg)
|
13
|
+
new.hexdigest(arg)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(klass = nil)
|
18
|
+
@digest_class = klass || self.class.digest_class
|
19
|
+
end
|
20
|
+
|
21
|
+
def hexdigest(arg)
|
22
|
+
@digest_class.hexdigest(arg).truncate(32)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -11,7 +11,7 @@ module Deface
|
|
11
11
|
def validate_original(match)
|
12
12
|
match = match.map(&:to_s).join if match.is_a? Array
|
13
13
|
|
14
|
-
hashed_original = Digest::SHA1.hexdigest(match.to_s.gsub(/\s/, ''))
|
14
|
+
hashed_original = ::Digest::SHA1.hexdigest(match.to_s.gsub(/\s/, ''))
|
15
15
|
|
16
16
|
if @args[:original].present?
|
17
17
|
valid = @args[:original] == hashed_original
|
data/lib/deface/override.rb
CHANGED
@@ -185,7 +185,8 @@ module Deface
|
|
185
185
|
# used to determine if an override has changed
|
186
186
|
#
|
187
187
|
def digest
|
188
|
-
|
188
|
+
to_hash = @args.keys.map(&:to_s).sort.concat(@args.values.map(&:to_s).sort).join
|
189
|
+
Deface::Digest.hexdigest(to_hash)
|
189
190
|
end
|
190
191
|
|
191
192
|
# Creates MD5 of all overrides that apply to a particular
|
@@ -195,8 +196,8 @@ module Deface
|
|
195
196
|
#
|
196
197
|
def self.digest(details)
|
197
198
|
overrides = self.find(details)
|
198
|
-
|
199
|
-
Digest
|
199
|
+
to_hash = overrides.inject('') { |digest, override| digest << override.digest }
|
200
|
+
Deface::Digest.hexdigest(to_hash)
|
200
201
|
end
|
201
202
|
|
202
203
|
def self.all
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module Deface
|
6
|
+
describe Digest do
|
7
|
+
it "should use MD5 by default" do
|
8
|
+
expect(Digest.new.hexdigest("123")).to eq "202cb962ac59075b964b07152d234b70"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should use user-provided digest" do
|
12
|
+
digest = double("digest")
|
13
|
+
expect(digest).to receive(:hexdigest).with("to_digest").and_return("digested")
|
14
|
+
expect(Digest.new(digest).hexdigest("to_digest")).to eq "digested"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should truncate digest to 32 characters" do
|
18
|
+
digest = double("digest")
|
19
|
+
expect(digest).to receive(:hexdigest).with("to_digest").and_return("a" * 50)
|
20
|
+
expect(Digest.new(digest).hexdigest("to_digest").size).to eq 32
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deface
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.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:
|
11
|
+
date: 2018-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -212,6 +212,7 @@ files:
|
|
212
212
|
- lib/deface/actions/surround_action.rb
|
213
213
|
- lib/deface/actions/surround_contents.rb
|
214
214
|
- lib/deface/applicator.rb
|
215
|
+
- lib/deface/digest.rb
|
215
216
|
- lib/deface/dsl/context.rb
|
216
217
|
- lib/deface/dsl/loader.rb
|
217
218
|
- lib/deface/environment.rb
|
@@ -267,6 +268,7 @@ files:
|
|
267
268
|
- spec/deface/actions/surround_contents_spec.rb
|
268
269
|
- spec/deface/actions/surround_spec.rb
|
269
270
|
- spec/deface/applicator_spec.rb
|
271
|
+
- spec/deface/digest_spec.rb
|
270
272
|
- spec/deface/dsl/context_spec.rb
|
271
273
|
- spec/deface/dsl/loader_spec.rb
|
272
274
|
- spec/deface/environment_spec.rb
|
@@ -302,7 +304,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
302
304
|
version: '0'
|
303
305
|
requirements: []
|
304
306
|
rubyforge_project:
|
305
|
-
rubygems_version: 2.6.
|
307
|
+
rubygems_version: 2.6.10
|
306
308
|
signing_key:
|
307
309
|
specification_version: 4
|
308
310
|
summary: Deface is a library that allows you to customize ERB, Haml and Slim views
|
@@ -333,6 +335,7 @@ test_files:
|
|
333
335
|
- spec/deface/actions/surround_contents_spec.rb
|
334
336
|
- spec/deface/actions/surround_spec.rb
|
335
337
|
- spec/deface/applicator_spec.rb
|
338
|
+
- spec/deface/digest_spec.rb
|
336
339
|
- spec/deface/dsl/context_spec.rb
|
337
340
|
- spec/deface/dsl/loader_spec.rb
|
338
341
|
- spec/deface/environment_spec.rb
|