I have two questions. 1. Why should buildr invoke a FileTask given to the exclude() method? For the include() method, I understand and appreciate the feature, but I don't understand the point for the exclude method.
2. Why two boolean values in the 'should respond to :exclude with a FileTask, use these exclusion patterns and depend on those tasks' spec instead of one? lacton On Fri, Mar 26, 2010 at 10:07 PM, <[email protected]> wrote: > 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 } > + �[email protected] @include.select {|f| f.is_a?(Rake::FileTask)} > + �[email protected] @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 > + �[email protected]('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 > + �[email protected]('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 > + > �[email protected]('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']) > + �[email protected] > + file1.should be_true > + file2.should be_true > + end > > it 'should copy files over' do > @filter.from('src').into('target').run > > >
