deface 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 362600d10ec6ef2e0156d59d64d4dd8f3fb92a20
4
- data.tar.gz: 9900d892be3f317070b21aa8f0d81d2c12d9b44b
3
+ metadata.gz: 502de62f408e71f17bd0754e127f96fffbe75972
4
+ data.tar.gz: 279f46ffaf3840eba89f84b4523e67df977656c4
5
5
  SHA512:
6
- metadata.gz: 665ab9e4c61bfcb42d9812688f7d3abdd5f8a79724c0e7e4f7be062f2abff6e5c578644d6088cf6786110fca1cb878920be2e37cfac1f3841d990a37f2a67e0e
7
- data.tar.gz: 46e41b81bb39faa7bb21b5f7581c66f0edc73e423b80ddd7b5519a23a3f087caf0de53e739939576212baa87fe461fab15752d67f5c36d72ef836b191855cc3a
6
+ metadata.gz: d7601eb9876b5731d7c1742a79b509f2fc03e3e670ce31283f8e642f4e7a6f77840c3f6ffdc68955517c548723768ce2b5f1a607eca39be63af813150ab8e4c9
7
+ data.tar.gz: d74468452500ad67931db222bf4eb4697cab2a6530471e6e10e46dbda1e9d3bc78f00956588457e8091be186ff4a290b961931820a5e10b2fc17581c229667c5
data/.gitignore CHANGED
@@ -4,3 +4,5 @@ pkg
4
4
  Gemfile.lock
5
5
  coverage/
6
6
  .bundle/
7
+ gemfiles/*.lock
8
+ /.idea
@@ -1,12 +1,16 @@
1
1
  script: "bundle exec rake"
2
2
  rvm:
3
- - 1.9.3
4
- - 2.0.0
3
+ - 2.1.10
4
+ - 2.2.5
5
+ - 2.3.1
5
6
  gemfile:
6
- - gemfiles/rails3_1.gemfile
7
- - gemfiles/rails3_2.gemfile
8
- - gemfiles/rails4_0.gemfile
9
- - gemfiles/haml4_0.gemfile
7
+ - gemfiles/rails_4.1.gemfile
8
+ - gemfiles/rails_4.2.gemfile
9
+ - gemfiles/rails_5.0.gemfile
10
+ matrix:
11
+ exclude:
12
+ - rvm: 2.1.10
13
+ gemfile: gemfiles/rails_5.0.gemfile
10
14
  notifications:
11
15
  email:
12
16
  - brian@spreecommerce.com
@@ -0,0 +1,11 @@
1
+ appraise 'rails-4.1' do
2
+ gem 'rails', '~> 4.1.0'
3
+ end
4
+
5
+ appraise 'rails-4.2' do
6
+ gem 'rails', '~> 4.2.0'
7
+ end
8
+
9
+ appraise 'rails-5.0' do
10
+ gem 'rails', '>= 5.0.0.alpha', '< 5.1'
11
+ end
data/Gemfile CHANGED
@@ -1,7 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'rails', ENV['RAILS'] || '~> 3.2.13'
4
-
5
3
  group :test do
6
4
  gem 'test-unit'
7
5
  gem 'pry'
@@ -1,4 +1,8 @@
1
- [![Build Status](https://travis-ci.org/DefaceCommunity/deface.svg?branch=master)](https://travis-ci.org/DefaceCommunity/deface)
1
+ <p style="float:right;">
2
+ <a href="http://secure.travis-ci.org/spree/deface">
3
+ <img src="https://secure.travis-ci.org/spree/deface.png?branch=master">
4
+ </a>
5
+ </p>
2
6
 
3
7
  Deface
4
8
  ======
@@ -105,7 +109,7 @@ You should save your overrides in the ````app/overrides````, normally one overri
105
109
 
106
110
  * <tt>:disabled</tt> - When set to true the override will not be applied.
107
111
 
108
- * <tt>:original</tt> - String containing original markup that is being overridden. If supplied Deface will log when the original markup changes, which helps highlight overrides that need attention when upgrading versions of the source application. Only really warranted for :replace overrides. NB: All whitespace is stripped before comparison.
112
+ * <tt>:original</tt> - Either a string containing the original markup that is being overridden, or a string that is the SHA1 digest of the original markup. If supplied Deface will log when the original markup changes, which helps highlight overrides that need attention when upgrading versions of the source application. Only really warranted for :replace overrides. NB: All whitespace is stripped before comparison. To generate the SHA1 digest do: `Digest::SHA1.hexdigest(original_markup_string.gsub(/\s/, ''))`
109
113
 
110
114
  * <tt>:closing_selector</tt> - A second css selector targeting an end element, allowing you to select a range of elements to apply an action against. The :closing_selector only supports the :replace, :remove and :replace_contents actions, and the end element must be a sibling of the first/starting element. Note the CSS general sibling selector (~) is used to match the first element after the opening selector (see below for an example).
111
115
 
@@ -190,7 +194,7 @@ Remove an entire ERB if statement (and all it's contents) in the 'admin/products
190
194
  Deface::Override.new(:virtual_path => 'admin/products/index',
191
195
  :name => "remove_if_statement",
192
196
  :remove => "erb[silent]:contains('if @product.sold?')",
193
- :closing_selector => "erb[silent]:contains('end')"
197
+ :closing_selector => "erb[silent]:contains('end')")
194
198
  ```
195
199
 
196
200
  ### Scope
@@ -344,16 +348,37 @@ Production & Precompiling
344
348
 
345
349
  Deface now supports precompiling where all overrides are loaded and applied to the original views and the resulting templates are then saved to your application's `app/compiled_views` directory. To precompile run:
346
350
 
347
- bundle exec rake deface:precompile
351
+ DEFACE_ENABLED=true bundle exec rake deface:precompile
348
352
 
349
353
  It's important to disable Deface once precompiling is used to prevent overrides getting applied twice. To disable add the following line to your application's `production.rb` file:
350
354
 
351
355
  ```ruby
352
- config.deface.enabled = false
356
+ config.deface.enabled = ENV['DEFACE_ENABLED'] == 'true'
353
357
  ```
354
358
 
355
359
  NOTE: You can also use precompiling in development mode.
356
360
 
361
+ ### Adding to Capistrano
362
+
363
+ Adding the following to your `deploy.rb` will automatically compile the views during deploy
364
+
365
+ ```ruby
366
+ namespace :deface do
367
+ desc "Pre-compile Deface overrides into templates"
368
+ task :precompile do
369
+ on roles(:app) do
370
+ within release_path do
371
+ with rails_env: fetch(:rails_env), deface_enabled: true do
372
+ execute :rake, 'deface:precompile'
373
+ end
374
+ end
375
+ end
376
+ end
377
+ end
378
+
379
+ after 'deploy:updated', 'deface:precompile'
380
+ ```
381
+
357
382
 
358
383
  Demo & Testing
359
384
  --------------
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "deface"
3
- s.version = "1.0.2"
3
+ s.version = "1.1.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."
@@ -10,19 +10,20 @@ Gem::Specification.new do |s|
10
10
  ]
11
11
  s.files = `git ls-files`.split("\n")
12
12
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
- s.homepage = "https://github.com/DefaceCommunity/deface"
13
+ s.homepage = "https://github.com/spree/deface"
14
14
  s.rdoc_options = ["--charset=UTF-8"]
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
18
  s.add_dependency('nokogiri', '~> 1.6.0')
19
- s.add_dependency('rails', '>= 3.1')
19
+ s.add_dependency('rails', '>= 4.1')
20
20
  s.add_dependency('colorize', '>= 0.5.8')
21
21
  s.add_dependency('polyglot')
22
22
 
23
+ s.add_development_dependency('appraisal')
23
24
  s.add_development_dependency('rspec', '>= 3.1.0')
24
- s.add_development_dependency('haml', '>= 3.1.4')
25
- s.add_development_dependency('slim', '>= 2.0.0') # 2.0.1 breaks slim loader specs
25
+ s.add_development_dependency('haml', '~> 4.0')
26
+ s.add_development_dependency('slim', '~> 3.0')
26
27
  s.add_development_dependency('simplecov', '>= 0.6.4')
27
28
  s.add_development_dependency('generator_spec', '~> 0.8')
28
29
  end
@@ -0,0 +1,13 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 4.1.0"
6
+
7
+ group :test do
8
+ gem "test-unit"
9
+ gem "pry"
10
+ gem "pry-byebug"
11
+ end
12
+
13
+ gemspec :path => "../"
@@ -0,0 +1,13 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 4.2.0"
6
+
7
+ group :test do
8
+ gem "test-unit"
9
+ gem "pry"
10
+ gem "pry-byebug"
11
+ end
12
+
13
+ gemspec :path => "../"
@@ -0,0 +1,13 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", ">= 5.0.0.alpha", "< 5.1"
6
+
7
+ group :test do
8
+ gem "test-unit"
9
+ gem "pry"
10
+ gem "pry-byebug"
11
+ end
12
+
13
+ gemspec :path => "../"
@@ -36,7 +36,7 @@ module Deface
36
36
  initializer "deface.tweak_eager_loading", :before => :set_load_path do |app|
37
37
 
38
38
  # application
39
- app.config.eager_load_paths.reject! {|path| path =~ /app\/overrides\z/ }
39
+ app.config.eager_load_paths.reject! {|path| path.to_s =~ /app\/overrides\z/ }
40
40
 
41
41
  # railites / engines / extensions
42
42
  railties = if Rails.version >= "4.0"
@@ -47,7 +47,7 @@ module Deface
47
47
 
48
48
  railties.each do |railtie|
49
49
  next unless railtie.respond_to?(:root) && railtie.config.respond_to?(:eager_load_paths)
50
- railtie.config.eager_load_paths.reject! {|path| path =~ /app\/overrides\z/ }
50
+ railtie.config.eager_load_paths.reject! {|path| path.to_s =~ /app\/overrides\z/ }
51
51
  end
52
52
  end
53
53
 
@@ -33,7 +33,8 @@ module Deface
33
33
  end
34
34
 
35
35
  it "should return converted source for template containing slim" do
36
- expect(load_template_source("shared/public", false).gsub(/\s/, '')).to include('print_information')
36
+ result = "<divid=\"content\"><divclass=\"left\"><p><%=::Temple::Utils.escape_html_safe((print_information))%></p></div><divclass=\"right\"<%_slim_codeattributes1=@right;if_slim_codeattributes1;if_slim_codeattributes1==true%>id=\"\"<%else%>id=\"<%=::Temple::Utils.escape_html_safe((_slim_codeattributes1))%>\"<%end;end%>><%=::Temple::Utils.escape_html_safe((render:partial=>\"sidebar\"))%></div></div>"
37
+ expect(load_template_source("shared/public", false).gsub(/\s/, '')).to eq result
37
38
  end
38
39
 
39
40
  it "should return source for namespaced template" do
@@ -54,7 +55,6 @@ module Deface
54
55
  Deface::Override.new(:virtual_path => "shared/person", :name => "shared#person", :replace => "p", :text => "<h1>Argh!</h1>")
55
56
  Deface::Override.new(:virtual_path => "shared/_hello", :name => "shared#hello", :replace_contents => "div#message", :text => "<%= 'Goodbye World!' %>")
56
57
  Deface::Override.new(:virtual_path => "shared/pirate", :name => "shared#pirate", :replace => "p", :text => "<h1>Argh!</h1>")
57
- Deface::Override.new(:virtual_path => "shared/public", :name => "shared#public", :replace => "p", :text => "<h1>Ahoy!</h1>")
58
58
  Deface::Override.new(:virtual_path => "admin/posts/index", :name => "admin#posts#index", :replace => "h1", :text => "<h1>Argh!</h1>")
59
59
  end
60
60
 
@@ -83,7 +83,8 @@ module Deface
83
83
  end
84
84
 
85
85
  it "should return converted and overridden source for template containing slim" do
86
- expect(load_template_source("shared/public", false).gsub(/\s/, '')).to include("<h1>Ahoy!</h1>")
86
+ result = "<divid=\"content\"><divclass=\"left\"><p><%=::Temple::Utils.escape_html_safe((print_information))%></p></div><divclass=\"right\"<%_slim_codeattributes1=@right;if_slim_codeattributes1;if_slim_codeattributes1==true%>id=\"\"<%else%>id=\"<%=::Temple::Utils.escape_html_safe((_slim_codeattributes1))%>\"<%end;end%>><%=::Temple::Utils.escape_html_safe((render:partial=>\"sidebar\"))%></div></div>"
87
+ expect(load_template_source("shared/public", false).gsub(/\s/, '')).to eq result
87
88
  end
88
89
 
89
90
  it "should return source for namespaced template including overrides" do
@@ -1,11 +1,14 @@
1
1
  require 'spec_helper'
2
2
  require 'deface/utils/failure_finder'
3
3
 
4
+ require 'active_support/testing/stream' if Rails::VERSION::MAJOR >= 5
5
+
4
6
  module Deface
5
7
  module Utils
6
8
  describe FailureFinder do
7
9
  include Deface::Utils::FailureFinder
8
10
  include Deface::TemplateHelper
11
+ include ActiveSupport::Testing::Stream if Rails::VERSION::MAJOR >= 5
9
12
  include_context "mock Rails.application"
10
13
 
11
14
  before do
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.0.2
4
+ version: 1.1.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: 2015-11-13 00:00:00.000000000 Z
11
+ date: 2016-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '3.1'
33
+ version: '4.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '3.1'
40
+ version: '4.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: colorize
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: appraisal
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rspec
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -84,30 +98,30 @@ dependencies:
84
98
  name: haml
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - ">="
101
+ - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: 3.1.4
103
+ version: '4.0'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - ">="
108
+ - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: 3.1.4
110
+ version: '4.0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: slim
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - ">="
115
+ - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: 2.0.0
117
+ version: '3.0'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - ">="
122
+ - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: 2.0.0
124
+ version: '3.0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: simplecov
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -148,16 +162,16 @@ files:
148
162
  - ".gitignore"
149
163
  - ".rspec"
150
164
  - ".travis.yml"
165
+ - Appraisals
151
166
  - CHANGELOG.markdown
152
167
  - Gemfile
153
168
  - MIT-LICENSE
154
169
  - README.markdown
155
170
  - Rakefile
156
171
  - deface.gemspec
157
- - gemfiles/haml4_0.gemfile
158
- - gemfiles/rails3_1.gemfile
159
- - gemfiles/rails3_2.gemfile
160
- - gemfiles/rails4_0.gemfile
172
+ - gemfiles/rails_4.1.gemfile
173
+ - gemfiles/rails_4.2.gemfile
174
+ - gemfiles/rails_5.0.gemfile
161
175
  - init.rb
162
176
  - lib/deface.rb
163
177
  - lib/deface/action_view_extensions.rb
@@ -248,7 +262,7 @@ files:
248
262
  - spec/spec_helper.rb
249
263
  - tasks/precompile.rake
250
264
  - tasks/utils.rake
251
- homepage: https://github.com/DefaceCommunity/deface
265
+ homepage: https://github.com/spree/deface
252
266
  licenses: []
253
267
  metadata: {}
254
268
  post_install_message:
@@ -268,9 +282,47 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
282
  version: '0'
269
283
  requirements: []
270
284
  rubyforge_project:
271
- rubygems_version: 2.4.5
285
+ rubygems_version: 2.5.1
272
286
  signing_key:
273
287
  specification_version: 4
274
288
  summary: Deface is a library that allows you to customize ERB, Haml and Slim views
275
289
  in Rails
276
- test_files: []
290
+ test_files:
291
+ - spec/assets/admin/posts/index.html.erb
292
+ - spec/assets/dummy_app/overrides/posts/index/app_override.html.erb.deface
293
+ - spec/assets/dummy_app/overrides/posts/precompileme/precompileme.html.erb.deface
294
+ - spec/assets/dummy_engine/overrides/users/index/engine_override.html.erb.deface
295
+ - spec/assets/posts/precompileme.html.erb
296
+ - spec/assets/shared/_hello.html.haml
297
+ - spec/assets/shared/_hi.html.slim
298
+ - spec/assets/shared/_post.html.erb
299
+ - spec/assets/shared/person.html.erb
300
+ - spec/assets/shared/pirate.html.haml
301
+ - spec/assets/shared/public.html.slim
302
+ - spec/deface/action_view_template_spec.rb
303
+ - spec/deface/actions/add_to_attributes_spec.rb
304
+ - spec/deface/actions/insert_after_spec.rb
305
+ - spec/deface/actions/insert_before_spec.rb
306
+ - spec/deface/actions/insert_bottom_spec.rb
307
+ - spec/deface/actions/insert_top_spec.rb
308
+ - spec/deface/actions/remove_from_attributes_spec.rb
309
+ - spec/deface/actions/remove_spec.rb
310
+ - spec/deface/actions/replace_contents_spec.rb
311
+ - spec/deface/actions/replace_spec.rb
312
+ - spec/deface/actions/set_attributes_spec.rb
313
+ - spec/deface/actions/surround_contents_spec.rb
314
+ - spec/deface/actions/surround_spec.rb
315
+ - spec/deface/applicator_spec.rb
316
+ - spec/deface/dsl/context_spec.rb
317
+ - spec/deface/dsl/loader_spec.rb
318
+ - spec/deface/environment_spec.rb
319
+ - spec/deface/haml_converter_spec.rb
320
+ - spec/deface/override_spec.rb
321
+ - spec/deface/parser_spec.rb
322
+ - spec/deface/precompiler_spec.rb
323
+ - spec/deface/search_spec.rb
324
+ - spec/deface/slim_converter_spec.rb
325
+ - spec/deface/template_helper_spec.rb
326
+ - spec/deface/utils/failure_finder_spec.rb
327
+ - spec/generators/deface/override_generator_spec.rb
328
+ - spec/spec_helper.rb
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'haml', '~> 4.0.0'
4
-
5
- gemspec :path=>"../"
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem "rails", "~> 3.1.0"
4
-
5
- gemspec :path=>"../"
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem "rails", "~> 3.2.0"
4
-
5
- gemspec :path=>"../"
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem "rails", "~> 4.0.0.rc1"
4
-
5
- gemspec :path => "../"