deface 0.9.1 → 1.0.0.rc1
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.
- data/.gitignore +1 -0
- data/.rspec +3 -0
- data/.travis.yml +1 -0
- data/README.markdown +139 -59
- data/deface.gemspec +4 -2
- data/gemfiles/haml3_2.gemfile +5 -0
- data/lib/deface.rb +28 -1
- data/lib/deface/action_view_extensions.rb +7 -1
- data/lib/deface/actions/action.rb +19 -0
- data/lib/deface/actions/add_to_attributes.rb +15 -0
- data/lib/deface/actions/attribute_action.rb +33 -0
- data/lib/deface/actions/element_action.rb +13 -0
- data/lib/deface/actions/insert_after.rb +9 -0
- data/lib/deface/actions/insert_before.rb +9 -0
- data/lib/deface/actions/insert_bottom.rb +14 -0
- data/lib/deface/actions/insert_top.rb +14 -0
- data/lib/deface/actions/remove.rb +13 -0
- data/lib/deface/actions/remove_from_attributes.rb +13 -0
- data/lib/deface/actions/replace.rb +14 -0
- data/lib/deface/actions/replace_contents.rb +19 -0
- data/lib/deface/actions/set_attributes.rb +12 -0
- data/lib/deface/actions/surround.rb +24 -0
- data/lib/deface/actions/surround_action.rb +15 -0
- data/lib/deface/actions/surround_contents.rb +33 -0
- data/lib/deface/applicator.rb +35 -191
- data/lib/deface/dsl/context.rb +7 -3
- data/lib/deface/dsl/loader.rb +5 -2
- data/lib/deface/environment.rb +31 -1
- data/lib/deface/haml_converter.rb +33 -5
- data/lib/deface/matchers/element.rb +13 -0
- data/lib/deface/matchers/range.rb +52 -0
- data/lib/deface/override.rb +28 -57
- data/lib/deface/sources/copy.rb +15 -0
- data/lib/deface/sources/cut.rb +25 -0
- data/lib/deface/sources/erb.rb +9 -0
- data/lib/deface/sources/haml.rb +14 -0
- data/lib/deface/sources/partial.rb +13 -0
- data/lib/deface/sources/source.rb +11 -0
- data/lib/deface/sources/template.rb +13 -0
- data/lib/deface/sources/text.rb +9 -0
- data/lib/deface/utils/failure_finder.rb +41 -0
- data/spec/deface/action_view_template_spec.rb +28 -2
- data/spec/deface/actions/add_to_attributes_spec.rb +62 -0
- data/spec/deface/actions/insert_after_spec.rb +19 -0
- data/spec/deface/actions/insert_before_spec.rb +19 -0
- data/spec/deface/actions/insert_bottom_spec.rb +28 -0
- data/spec/deface/actions/insert_top_spec.rb +28 -0
- data/spec/deface/actions/remove_from_attributes_spec.rb +81 -0
- data/spec/deface/actions/remove_spec.rb +30 -0
- data/spec/deface/actions/replace_contents_spec.rb +29 -0
- data/spec/deface/actions/replace_spec.rb +52 -0
- data/spec/deface/actions/set_attributes_spec.rb +62 -0
- data/spec/deface/actions/surround_contents_spec.rb +57 -0
- data/spec/deface/actions/surround_spec.rb +57 -0
- data/spec/deface/applicator_spec.rb +0 -354
- data/spec/deface/dsl/context_spec.rb +14 -7
- data/spec/deface/dsl/loader_spec.rb +12 -4
- data/spec/deface/override_spec.rb +26 -3
- data/spec/deface/template_helper_spec.rb +11 -0
- data/spec/deface/utils/failure_finder_spec.rb +76 -0
- data/spec/spec_helper.rb +21 -2
- data/tasks/utils.rake +24 -0
- metadata +91 -14
| @@ -3,15 +3,13 @@ require 'spec_helper' | |
| 3 3 | 
             
            require 'deface/dsl/context'
         | 
| 4 4 |  | 
| 5 5 | 
             
            describe Deface::DSL::Context do
         | 
| 6 | 
            -
              include_context "mock Rails"
         | 
| 6 | 
            +
              include_context "mock Rails.application"
         | 
| 7 7 |  | 
| 8 8 | 
             
              context '#create_override' do
         | 
| 9 9 | 
             
                subject { context = Deface::DSL::Context.new('sample_name') }
         | 
| 10 10 |  | 
| 11 11 | 
             
                def override_should_be_created_with(expected_hash)
         | 
| 12 | 
            -
                  Deface::Override.should_receive(:new).with | 
| 13 | 
            -
                    :name => 'sample_name'
         | 
| 14 | 
            -
                  ))
         | 
| 12 | 
            +
                  Deface::Override.should_receive(:new).with hash_including(expected_hash.reverse_merge(:name => 'sample_name'))
         | 
| 15 13 |  | 
| 16 14 | 
             
                  subject.create_override
         | 
| 17 15 | 
             
                end
         | 
| @@ -27,7 +25,8 @@ describe Deface::DSL::Context do | |
| 27 25 | 
             
                end
         | 
| 28 26 |  | 
| 29 27 | 
             
                context 'actions' do
         | 
| 30 | 
            -
                  Deface:: | 
| 28 | 
            +
                  Deface::DEFAULT_ACTIONS.each do |action|
         | 
| 29 | 
            +
                    action = action.to_sym
         | 
| 31 30 | 
             
                    it "should use value set with ##{action}" do
         | 
| 32 31 | 
             
                      subject.send(action, "#{action}/selector")
         | 
| 33 32 |  | 
| @@ -37,7 +36,7 @@ describe Deface::DSL::Context do | |
| 37 36 |  | 
| 38 37 | 
             
                  it 'should generate a warning if two action values are specified' do
         | 
| 39 38 | 
             
                    subject.insert_top('selector')
         | 
| 40 | 
            -
             | 
| 39 | 
            +
             | 
| 41 40 | 
             
                    logger = mock('logger')
         | 
| 42 41 | 
             
                    Rails.should_receive(:logger).and_return(logger)
         | 
| 43 42 | 
             
                    logger.should_receive(:error).with("\e[1;32mDeface: [WARNING]\e[0m Multiple action methods have been called. The last one will be used.")
         | 
| @@ -56,7 +55,8 @@ describe Deface::DSL::Context do | |
| 56 55 | 
             
                end
         | 
| 57 56 |  | 
| 58 57 | 
             
                context 'sources' do
         | 
| 59 | 
            -
                  Deface:: | 
| 58 | 
            +
                  Deface::DEFAULT_SOURCES.each do |source|
         | 
| 59 | 
            +
                    source = source.to_sym
         | 
| 60 60 | 
             
                    it "should use value set with ##{source}" do
         | 
| 61 61 | 
             
                      subject.send(source, "#{source} value")
         | 
| 62 62 |  | 
| @@ -145,5 +145,12 @@ describe Deface::DSL::Context do | |
| 145 145 |  | 
| 146 146 | 
             
                  override_should_be_created_with(:disabled => false)
         | 
| 147 147 | 
             
                end
         | 
| 148 | 
            +
             | 
| 149 | 
            +
                it "should automatically namespace the override's name when namespaced is called" do
         | 
| 150 | 
            +
                  subject.namespaced
         | 
| 151 | 
            +
             | 
| 152 | 
            +
                  override_should_be_created_with(:namespaced => true)
         | 
| 153 | 
            +
                end
         | 
| 154 | 
            +
             | 
| 148 155 | 
             
              end
         | 
| 149 156 | 
             
            end
         | 
| @@ -138,14 +138,14 @@ describe Deface::DSL::Loader do | |
| 138 138 | 
             
                it 'should work in the simplest case' do
         | 
| 139 139 | 
             
                  example = "<!-- test 'command' --><h1>Wow!</h1>"
         | 
| 140 140 | 
             
                  dsl_commands, the_rest = Deface::DSL::Loader.extract_dsl_commands_from_erb(example)
         | 
| 141 | 
            -
                  dsl_commands.should == " | 
| 141 | 
            +
                  dsl_commands.should == "\ntest 'command'"
         | 
| 142 142 | 
             
                  the_rest.should == "<h1>Wow!</h1>"
         | 
| 143 143 | 
             
                end
         | 
| 144 144 |  | 
| 145 145 | 
             
                it 'should combine multiple comments' do
         | 
| 146 146 | 
             
                  example = "<!-- test 'command' --><!-- another 'command' --><h1>Wow!</h1>"
         | 
| 147 147 | 
             
                  dsl_commands, the_rest = Deface::DSL::Loader.extract_dsl_commands_from_erb(example)
         | 
| 148 | 
            -
                  dsl_commands.should == " | 
| 148 | 
            +
                  dsl_commands.should == "\ntest 'command'\nanother 'command'"
         | 
| 149 149 | 
             
                  the_rest.should == "<h1>Wow!</h1>"
         | 
| 150 150 | 
             
                end
         | 
| 151 151 |  | 
| @@ -159,16 +159,24 @@ describe Deface::DSL::Loader do | |
| 159 159 | 
             
                it 'should work with comments on own lines' do
         | 
| 160 160 | 
             
                  example = "<!-- test 'command' -->\n<!-- another 'command' -->\n<h1>Wow!</h1>"
         | 
| 161 161 | 
             
                  dsl_commands, the_rest = Deface::DSL::Loader.extract_dsl_commands_from_erb(example)
         | 
| 162 | 
            -
                  dsl_commands.should == " | 
| 162 | 
            +
                  dsl_commands.should == "\ntest 'command'\nanother 'command'"
         | 
| 163 163 | 
             
                  the_rest.should == "\n<h1>Wow!</h1>"
         | 
| 164 164 | 
             
                end
         | 
| 165 165 |  | 
| 166 166 | 
             
                it 'should work with newlines inside the comment' do
         | 
| 167 167 | 
             
                  example = "<!--\n test 'command'\nanother 'command'\n -->\n<h1>Wow!</h1>"
         | 
| 168 168 | 
             
                  dsl_commands, the_rest = Deface::DSL::Loader.extract_dsl_commands_from_erb(example)
         | 
| 169 | 
            -
                  dsl_commands.should == " | 
| 169 | 
            +
                  dsl_commands.should == "\ntest 'command'\nanother 'command'"
         | 
| 170 170 | 
             
                  the_rest.should == "\n<h1>Wow!</h1>"
         | 
| 171 171 | 
             
                end
         | 
| 172 | 
            +
             | 
| 173 | 
            +
                it 'should work with multiple commands on one line' do
         | 
| 174 | 
            +
                  example = %q{<!-- replace_contents 'h1 .title' closing_selector "div#intro" disabled namespaced --><h1>Wow!</h1>}
         | 
| 175 | 
            +
                  dsl_commands, the_rest = Deface::DSL::Loader.extract_dsl_commands_from_erb(example)
         | 
| 176 | 
            +
                  dsl_commands.should == "\nreplace_contents 'h1 .title'\nclosing_selector \"div#intro\"\ndisabled\nnamespaced"
         | 
| 177 | 
            +
                  the_rest.should == "<h1>Wow!</h1>"
         | 
| 178 | 
            +
                end
         | 
| 179 | 
            +
             | 
| 172 180 | 
             
              end
         | 
| 173 181 |  | 
| 174 182 | 
             
              context '.extract_dsl_commands_from_haml' do
         | 
| @@ -17,7 +17,7 @@ module Deface | |
| 17 17 | 
             
                end
         | 
| 18 18 |  | 
| 19 19 | 
             
                it "should have a sources method" do
         | 
| 20 | 
            -
                  Deface:: | 
| 20 | 
            +
                  Deface::DEFAULT_SOURCES.map(&:to_sym).should include(:text)
         | 
| 21 21 | 
             
                end
         | 
| 22 22 |  | 
| 23 23 | 
             
                it "should return correct selector" do
         | 
| @@ -268,6 +268,29 @@ module Deface | |
| 268 268 | 
             
                  end
         | 
| 269 269 | 
             
                end
         | 
| 270 270 |  | 
| 271 | 
            +
                describe "with :namespaced" do
         | 
| 272 | 
            +
                  before(:each) do
         | 
| 273 | 
            +
                    Deface::Override.current_railtie = 'SpreeEngine'
         | 
| 274 | 
            +
                    @override = Deface::Override.new(:virtual_path => 'sample_path', :name => 'sample_name', :replace => 'h1', :namespaced => true)
         | 
| 275 | 
            +
                  end
         | 
| 276 | 
            +
             | 
| 277 | 
            +
                  it "should namespace the override's name" do
         | 
| 278 | 
            +
                    @override.name.should == 'spree_engine_sample_name'
         | 
| 279 | 
            +
                  end
         | 
| 280 | 
            +
                end
         | 
| 281 | 
            +
             | 
| 282 | 
            +
                describe "with global namespaced option set to true" do
         | 
| 283 | 
            +
                  before(:each) do
         | 
| 284 | 
            +
                    Deface::Override.current_railtie = 'SpreeEngine'
         | 
| 285 | 
            +
                    Rails.application.config.deface.namespaced = true
         | 
| 286 | 
            +
                    @override = Deface::Override.new(:virtual_path => 'sample_path', :name => 'sample_name', :replace => 'h1')
         | 
| 287 | 
            +
                  end
         | 
| 288 | 
            +
             | 
| 289 | 
            +
                  it "should namespace the override's name" do
         | 
| 290 | 
            +
                    @override.name.should == 'spree_engine_sample_name'
         | 
| 291 | 
            +
                  end
         | 
| 292 | 
            +
                end
         | 
| 293 | 
            +
             | 
| 271 294 | 
             
                describe "#source_element" do
         | 
| 272 295 | 
             
                  before(:each) do
         | 
| 273 296 | 
             
                    @override = Deface::Override.new(:virtual_path => "posts/index", :name => "Posts#index", :replace => "h1", :text => "<%= method :opt => 'x' & 'y' %>")
         | 
| @@ -322,9 +345,9 @@ module Deface | |
| 322 345 | 
             
                    ActionController::Base.stub(:view_paths).and_return([File.join(File.dirname(__FILE__), '..', "assets")])
         | 
| 323 346 |  | 
| 324 347 | 
             
                    Rails.application.config.deface.overrides.all.clear
         | 
| 325 | 
            -
                    @override    = Deface::Override.new(:virtual_path => "posts/index", :name => "Posts#index", :partial => "shared/post", :replace => "h1")
         | 
| 348 | 
            +
                    @override    = Deface::Override.new(:virtual_path => "posts/index", :name => "Posts#index", :partial => "shared/post", :replace => "h1", :text => "<span>I'm text</span>")
         | 
| 326 349 | 
             
                    expect {
         | 
| 327 | 
            -
                      @replacement = Deface::Override.new(:virtual_path => "posts/index", :name => "Posts#index", : | 
| 350 | 
            +
                      @replacement = Deface::Override.new(:virtual_path => "posts/index", :name => "Posts#index", :erb => "<p>I do be a pirate!</p>")
         | 
| 328 351 | 
             
                    }.to change{Rails.application.config.deface.overrides.all.size}.by(0)
         | 
| 329 352 | 
             
                  end
         | 
| 330 353 |  | 
| @@ -76,5 +76,16 @@ module Deface | |
| 76 76 | 
             
                  end
         | 
| 77 77 |  | 
| 78 78 | 
             
                end
         | 
| 79 | 
            +
             | 
| 80 | 
            +
                describe "element_source" do
         | 
| 81 | 
            +
                  it "should return array of matches elements" do
         | 
| 82 | 
            +
                    element_source('<div><p class="pirate">Arrgh!</p><img src="/some/image.jpg"></div>', 'p.pirate').should == ["<p class=\"pirate\">Arrgh!</p>\n"]
         | 
| 83 | 
            +
                    element_source('<div><p class="pirate">Arrgh!</p><p>No pirates here...</p></div>', 'p').should ==  ["<p class=\"pirate\">Arrgh!</p>\n", "<p>No pirates here...</p>"]
         | 
| 84 | 
            +
                  end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
                  it "should return empty array for no matches" do
         | 
| 87 | 
            +
                    element_source('<div><p class="pirate">Arrgh!</p><img src="/some/image.jpg"></div>', 'span').should == []
         | 
| 88 | 
            +
                  end
         | 
| 89 | 
            +
                end
         | 
| 79 90 | 
             
              end
         | 
| 80 91 | 
             
            end
         | 
| @@ -0,0 +1,76 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
            require 'deface/utils/failure_finder'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module Deface
         | 
| 5 | 
            +
              module Utils
         | 
| 6 | 
            +
                describe FailureFinder do
         | 
| 7 | 
            +
                  include Deface::Utils::FailureFinder
         | 
| 8 | 
            +
                  include Deface::TemplateHelper
         | 
| 9 | 
            +
                  include_context "mock Rails.application"
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  before do
         | 
| 12 | 
            +
                    #stub view paths to be local spec/assets directory
         | 
| 13 | 
            +
                    ActionController::Base.stub(:view_paths).and_return([File.join(File.dirname(__FILE__), '../..', "assets")])
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  context "given failing overrides" do
         | 
| 17 | 
            +
                    before do
         | 
| 18 | 
            +
                      Deface::Override.new(:virtual_path => "shared/_post", :name => "good", :remove => "p")
         | 
| 19 | 
            +
                      Deface::Override.new(:virtual_path => "shared/_post", :name => "bad", :remove => "img")
         | 
| 20 | 
            +
                    end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                    context "overrides_by_virtual_path" do
         | 
| 23 | 
            +
                      it "should load template and apply overrides" do
         | 
| 24 | 
            +
                        fails = overrides_by_virtual_path('shared/_post')
         | 
| 25 | 
            +
                        count = fails.group_by{ |o| !o.failure.nil? }
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                        count[true].size.should == 1
         | 
| 28 | 
            +
                        count[true].first.name.should == 'bad'
         | 
| 29 | 
            +
                        count[false].size.should == 1
         | 
| 30 | 
            +
                        count[false].first.name.should == 'good'
         | 
| 31 | 
            +
                      end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                      it "should return nil for path virtual_path value" do
         | 
| 34 | 
            +
                        silence_stream(STDOUT) do
         | 
| 35 | 
            +
                          overrides_by_virtual_path('shared/_poster').should be_nil
         | 
| 36 | 
            +
                        end
         | 
| 37 | 
            +
                      end
         | 
| 38 | 
            +
                    end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                    context "output_results_by_virtual_path" do
         | 
| 41 | 
            +
                      it "should return count of failed overrides for given path" do
         | 
| 42 | 
            +
                        silence_stream(STDOUT) do
         | 
| 43 | 
            +
                          output_results_by_virtual_path('shared/_post').should == 1
         | 
| 44 | 
            +
                        end
         | 
| 45 | 
            +
                      end
         | 
| 46 | 
            +
                    end
         | 
| 47 | 
            +
                  end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                  context "given no failing overrides" do
         | 
| 50 | 
            +
                    before do
         | 
| 51 | 
            +
                      Deface::Override.new(:virtual_path => "shared/_post", :name => "good", :remove => "p")
         | 
| 52 | 
            +
                    end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                    context "overrides_by_virtual_path" do
         | 
| 55 | 
            +
                      it "should load template and apply overrides" do
         | 
| 56 | 
            +
                        fails = overrides_by_virtual_path('shared/_post')
         | 
| 57 | 
            +
                        count = fails.group_by{ |o| !o.failure.nil? }
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                        count.key?('true').should be_false 
         | 
| 60 | 
            +
                        count[false].size.should == 1
         | 
| 61 | 
            +
                        count[false].first.name.should == 'good'
         | 
| 62 | 
            +
                      end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                    end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                    context "output_results_by_virtual_path" do
         | 
| 67 | 
            +
                      it "should return count of failed overrides for given path" do
         | 
| 68 | 
            +
                        silence_stream(STDOUT) do
         | 
| 69 | 
            +
                          output_results_by_virtual_path('shared/_post').should == 0
         | 
| 70 | 
            +
                        end
         | 
| 71 | 
            +
                      end
         | 
| 72 | 
            +
                    end
         | 
| 73 | 
            +
                  end
         | 
| 74 | 
            +
                end
         | 
| 75 | 
            +
              end
         | 
| 76 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -1,4 +1,5 @@ | |
| 1 | 
            -
            require ' | 
| 1 | 
            +
            require 'simplecov'
         | 
| 2 | 
            +
            SimpleCov.start 'rails'
         | 
| 2 3 | 
             
            require 'rspec'
         | 
| 3 4 | 
             
            require 'action_view'
         | 
| 4 5 | 
             
            require 'action_controller'
         | 
| @@ -9,7 +10,10 @@ require 'haml' | |
| 9 10 | 
             
            require 'deface/haml_converter'
         | 
| 10 11 | 
             
            require 'time'
         | 
| 11 12 |  | 
| 12 | 
            -
            Haml | 
| 13 | 
            +
            if defined?(Haml::Options)
         | 
| 14 | 
            +
              # Haml 3.2 changes the default output format to HTML5
         | 
| 15 | 
            +
              Haml::Options.defaults[:format] = :xhtml
         | 
| 16 | 
            +
            end
         | 
| 13 17 |  | 
| 14 18 | 
             
            RSpec.configure do |config|
         | 
| 15 19 | 
             
              config.mock_framework = :rspec
         | 
| @@ -47,6 +51,8 @@ shared_context "mock Rails" do | |
| 47 51 |  | 
| 48 52 | 
             
                Time.stub :zone => mock('zone')
         | 
| 49 53 | 
             
                Time.zone.stub(:now).and_return Time.parse('1979-05-25')
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                require "haml/template/plugin"
         | 
| 50 56 | 
             
              end
         | 
| 51 57 | 
             
            end
         | 
| 52 58 |  | 
| @@ -58,3 +64,16 @@ shared_context "mock Rails.application" do | |
| 58 64 | 
             
                Rails.application.config.deface.haml_support = true
         | 
| 59 65 | 
             
              end
         | 
| 60 66 | 
             
            end
         | 
| 67 | 
            +
             | 
| 68 | 
            +
            # Dummy Deface instance for testing actions / applicator
         | 
| 69 | 
            +
            class Dummy
         | 
| 70 | 
            +
              extend Deface::Applicator::ClassMethods
         | 
| 71 | 
            +
              extend Deface::Search::ClassMethods
         | 
| 72 | 
            +
             | 
| 73 | 
            +
              attr_reader :parsed_document
         | 
| 74 | 
            +
             | 
| 75 | 
            +
              def self.all
         | 
| 76 | 
            +
                Rails.application.config.deface.overrides.all
         | 
| 77 | 
            +
              end
         | 
| 78 | 
            +
            end
         | 
| 79 | 
            +
             | 
    
        data/tasks/utils.rake
    CHANGED
    
    | @@ -1,7 +1,10 @@ | |
| 1 1 | 
             
            require 'deface'
         | 
| 2 | 
            +
            require 'deface/utils/failure_finder'
         | 
| 3 | 
            +
            require 'colorize'
         | 
| 2 4 |  | 
| 3 5 | 
             
            namespace :deface do
         | 
| 4 6 | 
             
              include Deface::TemplateHelper
         | 
| 7 | 
            +
              include Deface::Utils::FailureFinder
         | 
| 5 8 |  | 
| 6 9 | 
             
              desc 'Applies selectors to given partial/template, and returns match(s) source.'
         | 
| 7 10 | 
             
              task :test_selector, [:virtual_path, :selector] => [:environment] do |t, args|
         | 
| @@ -56,4 +59,25 @@ namespace :deface do | |
| 56 59 |  | 
| 57 60 | 
             
              end
         | 
| 58 61 |  | 
| 62 | 
            +
              desc 'Load and apply all overrides, and output results'
         | 
| 63 | 
            +
              task :test_all => [:environment] do |t|
         | 
| 64 | 
            +
                fail_count = Deface::Override.all.keys.map(&:to_s).inject(0) do |failed, virtual_path|
         | 
| 65 | 
            +
                  result = output_results_by_virtual_path(virtual_path)
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                  failed += result
         | 
| 68 | 
            +
                end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                if fail_count == 0
         | 
| 71 | 
            +
                  puts "\nEverything's looking good!".green
         | 
| 72 | 
            +
                  exit(0)
         | 
| 73 | 
            +
                else
         | 
| 74 | 
            +
                  puts "\nYou had a total of #{fail_count} failures.".red
         | 
| 75 | 
            +
                  exit(1)
         | 
| 76 | 
            +
                end
         | 
| 77 | 
            +
              end
         | 
| 78 | 
            +
             | 
| 79 | 
            +
              desc 'Report on failing overrides for a partial/template'
         | 
| 80 | 
            +
              task :failures_by_virtual_path, [:virtual_path] => [:environment] do |t,args|
         | 
| 81 | 
            +
                output_results_by_virtual_path(args[:virtual_path])
         | 
| 82 | 
            +
              end
         | 
| 59 83 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,19 +1,19 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: deface
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 5 | 
            -
              prerelease: 
         | 
| 4 | 
            +
              version: 1.0.0.rc1
         | 
| 5 | 
            +
              prerelease: 6
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| 8 8 | 
             
            - Brian D Quinn
         | 
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2012- | 
| 12 | 
            +
            date: 2012-09-18 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: nokogiri
         | 
| 16 | 
            -
              requirement: & | 
| 16 | 
            +
              requirement: &70318167536000 !ruby/object:Gem::Requirement
         | 
| 17 17 | 
             
                none: false
         | 
| 18 18 | 
             
                requirements:
         | 
| 19 19 | 
             
                - - ~>
         | 
| @@ -21,10 +21,10 @@ dependencies: | |
| 21 21 | 
             
                    version: 1.5.0
         | 
| 22 22 | 
             
              type: :runtime
         | 
| 23 23 | 
             
              prerelease: false
         | 
| 24 | 
            -
              version_requirements: * | 
| 24 | 
            +
              version_requirements: *70318167536000
         | 
| 25 25 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 26 26 | 
             
              name: rails
         | 
| 27 | 
            -
              requirement: & | 
| 27 | 
            +
              requirement: &70318167534880 !ruby/object:Gem::Requirement
         | 
| 28 28 | 
             
                none: false
         | 
| 29 29 | 
             
                requirements:
         | 
| 30 30 | 
             
                - - ~>
         | 
| @@ -32,21 +32,32 @@ dependencies: | |
| 32 32 | 
             
                    version: '3.1'
         | 
| 33 33 | 
             
              type: :runtime
         | 
| 34 34 | 
             
              prerelease: false
         | 
| 35 | 
            -
              version_requirements: * | 
| 35 | 
            +
              version_requirements: *70318167534880
         | 
| 36 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 37 | 
            +
              name: colorize
         | 
| 38 | 
            +
              requirement: &70318167534080 !ruby/object:Gem::Requirement
         | 
| 39 | 
            +
                none: false
         | 
| 40 | 
            +
                requirements:
         | 
| 41 | 
            +
                - - ! '>='
         | 
| 42 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 43 | 
            +
                    version: 0.5.8
         | 
| 44 | 
            +
              type: :runtime
         | 
| 45 | 
            +
              prerelease: false
         | 
| 46 | 
            +
              version_requirements: *70318167534080
         | 
| 36 47 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 37 48 | 
             
              name: rspec
         | 
| 38 | 
            -
              requirement: & | 
| 49 | 
            +
              requirement: &70318167533180 !ruby/object:Gem::Requirement
         | 
| 39 50 | 
             
                none: false
         | 
| 40 51 | 
             
                requirements:
         | 
| 41 52 | 
             
                - - ! '>='
         | 
| 42 53 | 
             
                  - !ruby/object:Gem::Version
         | 
| 43 | 
            -
                    version: 2. | 
| 54 | 
            +
                    version: 2.11.0
         | 
| 44 55 | 
             
              type: :development
         | 
| 45 56 | 
             
              prerelease: false
         | 
| 46 | 
            -
              version_requirements: * | 
| 57 | 
            +
              version_requirements: *70318167533180
         | 
| 47 58 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 48 59 | 
             
              name: haml
         | 
| 49 | 
            -
              requirement: & | 
| 60 | 
            +
              requirement: &70318167532080 !ruby/object:Gem::Requirement
         | 
| 50 61 | 
             
                none: false
         | 
| 51 62 | 
             
                requirements:
         | 
| 52 63 | 
             
                - - ! '>='
         | 
| @@ -54,7 +65,18 @@ dependencies: | |
| 54 65 | 
             
                    version: 3.1.4
         | 
| 55 66 | 
             
              type: :development
         | 
| 56 67 | 
             
              prerelease: false
         | 
| 57 | 
            -
              version_requirements: * | 
| 68 | 
            +
              version_requirements: *70318167532080
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            +
              name: simplecov
         | 
| 71 | 
            +
              requirement: &70318167531080 !ruby/object:Gem::Requirement
         | 
| 72 | 
            +
                none: false
         | 
| 73 | 
            +
                requirements:
         | 
| 74 | 
            +
                - - ! '>='
         | 
| 75 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 76 | 
            +
                    version: 0.6.4
         | 
| 77 | 
            +
              type: :development
         | 
| 78 | 
            +
              prerelease: false
         | 
| 79 | 
            +
              version_requirements: *70318167531080
         | 
| 58 80 | 
             
            description: Deface is a library that allows you to customize ERB & HAML views in
         | 
| 59 81 | 
             
              a Rails application without editing the underlying view.
         | 
| 60 82 | 
             
            email: brian@spreecommerce.com
         | 
| @@ -64,28 +86,57 @@ extra_rdoc_files: | |
| 64 86 | 
             
            - README.markdown
         | 
| 65 87 | 
             
            files:
         | 
| 66 88 | 
             
            - .gitignore
         | 
| 89 | 
            +
            - .rspec
         | 
| 67 90 | 
             
            - .travis.yml
         | 
| 68 91 | 
             
            - Gemfile
         | 
| 69 92 | 
             
            - MIT-LICENSE
         | 
| 70 93 | 
             
            - README.markdown
         | 
| 71 94 | 
             
            - Rakefile
         | 
| 72 95 | 
             
            - deface.gemspec
         | 
| 96 | 
            +
            - gemfiles/haml3_2.gemfile
         | 
| 73 97 | 
             
            - gemfiles/rails3_1.gemfile
         | 
| 74 98 | 
             
            - gemfiles/rails3_2.gemfile
         | 
| 75 99 | 
             
            - init.rb
         | 
| 76 100 | 
             
            - lib/deface.rb
         | 
| 77 101 | 
             
            - lib/deface/action_view_extensions.rb
         | 
| 102 | 
            +
            - lib/deface/actions/action.rb
         | 
| 103 | 
            +
            - lib/deface/actions/add_to_attributes.rb
         | 
| 104 | 
            +
            - lib/deface/actions/attribute_action.rb
         | 
| 105 | 
            +
            - lib/deface/actions/element_action.rb
         | 
| 106 | 
            +
            - lib/deface/actions/insert_after.rb
         | 
| 107 | 
            +
            - lib/deface/actions/insert_before.rb
         | 
| 108 | 
            +
            - lib/deface/actions/insert_bottom.rb
         | 
| 109 | 
            +
            - lib/deface/actions/insert_top.rb
         | 
| 110 | 
            +
            - lib/deface/actions/remove.rb
         | 
| 111 | 
            +
            - lib/deface/actions/remove_from_attributes.rb
         | 
| 112 | 
            +
            - lib/deface/actions/replace.rb
         | 
| 113 | 
            +
            - lib/deface/actions/replace_contents.rb
         | 
| 114 | 
            +
            - lib/deface/actions/set_attributes.rb
         | 
| 115 | 
            +
            - lib/deface/actions/surround.rb
         | 
| 116 | 
            +
            - lib/deface/actions/surround_action.rb
         | 
| 117 | 
            +
            - lib/deface/actions/surround_contents.rb
         | 
| 78 118 | 
             
            - lib/deface/applicator.rb
         | 
| 79 119 | 
             
            - lib/deface/dsl/context.rb
         | 
| 80 120 | 
             
            - lib/deface/dsl/loader.rb
         | 
| 81 121 | 
             
            - lib/deface/environment.rb
         | 
| 82 122 | 
             
            - lib/deface/haml_converter.rb
         | 
| 123 | 
            +
            - lib/deface/matchers/element.rb
         | 
| 124 | 
            +
            - lib/deface/matchers/range.rb
         | 
| 83 125 | 
             
            - lib/deface/original_validator.rb
         | 
| 84 126 | 
             
            - lib/deface/override.rb
         | 
| 85 127 | 
             
            - lib/deface/parser.rb
         | 
| 86 128 | 
             
            - lib/deface/railtie.rb
         | 
| 87 129 | 
             
            - lib/deface/search.rb
         | 
| 130 | 
            +
            - lib/deface/sources/copy.rb
         | 
| 131 | 
            +
            - lib/deface/sources/cut.rb
         | 
| 132 | 
            +
            - lib/deface/sources/erb.rb
         | 
| 133 | 
            +
            - lib/deface/sources/haml.rb
         | 
| 134 | 
            +
            - lib/deface/sources/partial.rb
         | 
| 135 | 
            +
            - lib/deface/sources/source.rb
         | 
| 136 | 
            +
            - lib/deface/sources/template.rb
         | 
| 137 | 
            +
            - lib/deface/sources/text.rb
         | 
| 88 138 | 
             
            - lib/deface/template_helper.rb
         | 
| 139 | 
            +
            - lib/deface/utils/failure_finder.rb
         | 
| 89 140 | 
             
            - spec/assets/admin/posts/index.html.erb
         | 
| 90 141 | 
             
            - spec/assets/dummy_app/overrides/posts/index/app_override.html.erb.deface
         | 
| 91 142 | 
             
            - spec/assets/dummy_engine/overrides/users/index/engine_override.html.erb.deface
         | 
| @@ -94,6 +145,18 @@ files: | |
| 94 145 | 
             
            - spec/assets/shared/person.html.erb
         | 
| 95 146 | 
             
            - spec/assets/shared/pirate.html.haml
         | 
| 96 147 | 
             
            - spec/deface/action_view_template_spec.rb
         | 
| 148 | 
            +
            - spec/deface/actions/add_to_attributes_spec.rb
         | 
| 149 | 
            +
            - spec/deface/actions/insert_after_spec.rb
         | 
| 150 | 
            +
            - spec/deface/actions/insert_before_spec.rb
         | 
| 151 | 
            +
            - spec/deface/actions/insert_bottom_spec.rb
         | 
| 152 | 
            +
            - spec/deface/actions/insert_top_spec.rb
         | 
| 153 | 
            +
            - spec/deface/actions/remove_from_attributes_spec.rb
         | 
| 154 | 
            +
            - spec/deface/actions/remove_spec.rb
         | 
| 155 | 
            +
            - spec/deface/actions/replace_contents_spec.rb
         | 
| 156 | 
            +
            - spec/deface/actions/replace_spec.rb
         | 
| 157 | 
            +
            - spec/deface/actions/set_attributes_spec.rb
         | 
| 158 | 
            +
            - spec/deface/actions/surround_contents_spec.rb
         | 
| 159 | 
            +
            - spec/deface/actions/surround_spec.rb
         | 
| 97 160 | 
             
            - spec/deface/applicator_spec.rb
         | 
| 98 161 | 
             
            - spec/deface/dsl/context_spec.rb
         | 
| 99 162 | 
             
            - spec/deface/dsl/loader_spec.rb
         | 
| @@ -103,6 +166,7 @@ files: | |
| 103 166 | 
             
            - spec/deface/parser_spec.rb
         | 
| 104 167 | 
             
            - spec/deface/search_spec.rb
         | 
| 105 168 | 
             
            - spec/deface/template_helper_spec.rb
         | 
| 169 | 
            +
            - spec/deface/utils/failure_finder_spec.rb
         | 
| 106 170 | 
             
            - spec/spec_helper.rb
         | 
| 107 171 | 
             
            - tasks/precompile.rake
         | 
| 108 172 | 
             
            - tasks/utils.rake
         | 
| @@ -122,9 +186,9 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 122 186 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 123 187 | 
             
              none: false
         | 
| 124 188 | 
             
              requirements:
         | 
| 125 | 
            -
              - - ! ' | 
| 189 | 
            +
              - - ! '>'
         | 
| 126 190 | 
             
                - !ruby/object:Gem::Version
         | 
| 127 | 
            -
                  version:  | 
| 191 | 
            +
                  version: 1.3.1
         | 
| 128 192 | 
             
            requirements: []
         | 
| 129 193 | 
             
            rubyforge_project: 
         | 
| 130 194 | 
             
            rubygems_version: 1.8.15
         | 
| @@ -140,6 +204,18 @@ test_files: | |
| 140 204 | 
             
            - spec/assets/shared/person.html.erb
         | 
| 141 205 | 
             
            - spec/assets/shared/pirate.html.haml
         | 
| 142 206 | 
             
            - spec/deface/action_view_template_spec.rb
         | 
| 207 | 
            +
            - spec/deface/actions/add_to_attributes_spec.rb
         | 
| 208 | 
            +
            - spec/deface/actions/insert_after_spec.rb
         | 
| 209 | 
            +
            - spec/deface/actions/insert_before_spec.rb
         | 
| 210 | 
            +
            - spec/deface/actions/insert_bottom_spec.rb
         | 
| 211 | 
            +
            - spec/deface/actions/insert_top_spec.rb
         | 
| 212 | 
            +
            - spec/deface/actions/remove_from_attributes_spec.rb
         | 
| 213 | 
            +
            - spec/deface/actions/remove_spec.rb
         | 
| 214 | 
            +
            - spec/deface/actions/replace_contents_spec.rb
         | 
| 215 | 
            +
            - spec/deface/actions/replace_spec.rb
         | 
| 216 | 
            +
            - spec/deface/actions/set_attributes_spec.rb
         | 
| 217 | 
            +
            - spec/deface/actions/surround_contents_spec.rb
         | 
| 218 | 
            +
            - spec/deface/actions/surround_spec.rb
         | 
| 143 219 | 
             
            - spec/deface/applicator_spec.rb
         | 
| 144 220 | 
             
            - spec/deface/dsl/context_spec.rb
         | 
| 145 221 | 
             
            - spec/deface/dsl/loader_spec.rb
         | 
| @@ -149,4 +225,5 @@ test_files: | |
| 149 225 | 
             
            - spec/deface/parser_spec.rb
         | 
| 150 226 | 
             
            - spec/deface/search_spec.rb
         | 
| 151 227 | 
             
            - spec/deface/template_helper_spec.rb
         | 
| 228 | 
            +
            - spec/deface/utils/failure_finder_spec.rb
         | 
| 152 229 | 
             
            - spec/spec_helper.rb
         |