buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toulm...@apache.org
Subject svn commit: r928060 - in /buildr/trunk: lib/buildr/core/filter.rb spec/core/common_spec.rb
Date Fri, 26 Mar 2010 21:07:02 GMT
Author: toulmean
Date: Fri Mar 26 21:07:02 2010
New Revision: 928060

URL: http://svn.apache.org/viewvc?rev=928060&view=rev
Log:
fix for BUILDR-408: Filter include() and exclude() should accept Rake tasks

Modified:
    buildr/trunk/lib/buildr/core/filter.rb
    buildr/trunk/spec/core/common_spec.rb

Modified: buildr/trunk/lib/buildr/core/filter.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/core/filter.rb?rev=928060&r1=928059&r2=928060&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/core/filter.rb (original)
+++ buildr/trunk/lib/buildr/core/filter.rb Fri Mar 26 21:07:02 2010
@@ -84,6 +84,8 @@ module Buildr
       return nil unless @target_dir
       unless @target
         @target = file(File.expand_path(@target_dir)) { |task| run if @target == task }
+        @target.enhance @include.select {|f| f.is_a?(Rake::FileTask)}
+        @target.enhance @exclude.select {|f| f.is_a?(Rake::FileTask)}
         @target.enhance copy_map.values
       end
       @target
@@ -215,6 +217,8 @@ module Buildr
         return File.fnmatch(pattern, file)
       when pattern.is_a?(Proc)
         return pattern.call(file)
+      when pattern.is_a?(Rake::FileTask)
+        return pattern.to_s.match(file)
       else
         raise "Cannot interpret pattern #{pattern}"
       end

Modified: buildr/trunk/spec/core/common_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/core/common_spec.rb?rev=928060&r1=928059&r2=928060&view=diff
==============================================================================
--- buildr/trunk/spec/core/common_spec.rb (original)
+++ buildr/trunk/spec/core/common_spec.rb Fri Mar 26 21:07:02 2010
@@ -318,6 +318,11 @@ describe Buildr::Filter do
     @filter.from('src').into('target').include(lambda {|file| file[-1, 1].to_i%2 == 0}).run
     Dir['target/*'].sort.should eql(['target/file2', 'target/file4'])
   end
+  
+  it 'should respond to :include with a FileTask and use these inclusion patterns' do
+    @filter.from('src').into('target').include(file('target/file2'), file('target/file4')).run
+    Dir['target/*'].sort.should eql(['target/file2', 'target/file4'])
+  end
 
   it 'should respond to :exclude and return self' do
     @filter.exclude('file').should be(@filter)
@@ -337,6 +342,21 @@ describe Buildr::Filter do
     @filter.from('src').into('target').exclude(lambda {|file| file[-1, 1].to_i%2 == 0}).run
     Dir['target/*'].sort.should eql(['target/file1', 'target/file3'])
   end
+  
+  it 'should respond to :exclude with a FileTask and use these exclusion patterns' do
+    @filter.from('src').into('target').exclude(file('target/file1'), file('target/file3')).run
+    Dir['target/*'].sort.should eql(['target/file2', 'target/file4'])
+  end
+  
+  it 'should respond to :exclude with a FileTask, use these exclusion patterns and depend
on those tasks' do
+    file1 = false
+    file2 = false
+    @filter.from('src').into('target').exclude(file('target/file1').enhance { file1 = true
}, file('target/file3').enhance {file2 = true }).run
+    Dir['target/*'].sort.should eql(['target/file2', 'target/file4'])
+    @filter.target.invoke
+    file1.should be_true
+    file2.should be_true
+  end
 
   it 'should copy files over' do
     @filter.from('src').into('target').run



Mime
View raw message