From 8424beee1e624e0835e28a946ac4664612839337 Mon Sep 17 00:00:00 2001 From: "James A. Rosen" Date: Sun, 19 Jun 2011 10:32:14 -0700 Subject: [PATCH] obey config.assets.prefix. Closes #1. Closes #2. Instead of doing an `rm -rf`, rely on `rake assets:clean`, which already obeys the setting. Unfortunately, the call to figure out the count of assets compiled would still need to have a directory specified. Thus, it's been removed. Less information, but the compilation still works fine. --- lib/guard/rails-assets.rb | 7 ++----- spec/guard/rails-assets_spec.rb | 9 ++------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/guard/rails-assets.rb b/lib/guard/rails-assets.rb index 108c620..ab044ac 100644 --- a/lib/guard/rails-assets.rb +++ b/lib/guard/rails-assets.rb @@ -26,12 +26,9 @@ module Guard def compile_assets puts 'Compiling rails assets' - result = system "rm -rf public/assets && bundle exec rake assets:precompile" + result = system "bundle exec rake assets:clean assets:precompile" if result - tree = `tree public/assets` - puts tree - summary = tree.split("\n").last - Notifier::notify summary, :title => 'Assets compiled' + Notifier::notify 'Assets compiled' else Notifier::notify 'see the details in the terminal', :title => "Can't compile assets", :image => :failed end diff --git a/spec/guard/rails-assets_spec.rb b/spec/guard/rails-assets_spec.rb index 61b4121..4dc915d 100644 --- a/spec/guard/rails-assets_spec.rb +++ b/spec/guard/rails-assets_spec.rb @@ -28,13 +28,12 @@ describe Guard::RailsAssets do describe 'asset compilation using CLI' do def stub_system_with result - subject.should_receive(:system).with("rm -rf public/assets && bundle exec rake assets:precompile").and_return result + subject.should_receive(:system).with("bundle exec rake assets:clean assets:precompile").and_return result end it 'should notify on success' do stub_system_with true - subject.should_receive(:`).with('tree public/assets').and_return "a\nb\n1 directory, 2 files" - Guard::Notifier.should_receive(:notify).with('1 directory, 2 files', :title => 'Assets compiled') + Guard::Notifier.should_receive(:notify).with('Assets compiled') subject.compile_assets end it 'should notify on failure' do @@ -44,8 +43,4 @@ describe Guard::RailsAssets do subject.compile_assets end end - - describe 'custom assets prefix' do - it 'should use given prefix' - end end