Jesús Gabriel y Galán wrote:
> On Mon, May 12, 2008 at 11:00 AM, Clement Ow
> <clement.ow / asia.bnpparibas.com> wrote:
>>
>>   sd_a.each do |sd|
>>   $source, $destination, $selections, $file_exception = sd
>>      src = File.join $source, $selections
>>      puts src
>>      d= $d1
>>      dst= File.join $destination, d
>>      test = File.join $source, $file_exception
> 
> Untested but change this:
> 
>>      src1 = Dir.glob(src) - Dir.glob(test)
> 
> to:
> 
> src1 = $file_exception.inject(Dir.glob(src)) {|result, ex| result -
> Dir.glob(ex)}
> 
> Also, doing a Dir.glob for each exception can be a lot, why not use
> regular expressions
> to remove from the result of the first glob? You will have to change
> the exceptions
> a little bit, but it might be worth it:
> 
> ["\.txt", "\.sql"].inject(Dir.glob("/home/jesus/*")) {|result, ex|
> result.reject{|x| x =~ Regexp.new(ex)}}
> 
> This removes from my home folder all files that match ".txt" and ".sql"
> 
> Hope this helps,
> 
> Jesus.

Hi Jesus,
nice slick code there using regexp ;) just wondering if there would be a 
possibility of having a different set of file exceptions for different 
file paths. cause at the moment, there can only be one specific file 
exceptions for every file path, which might be hard in the event where 
we would need to cater to different source paths. Prolly a few arrays in 
file exception?
-- 
Posted via http://www.ruby-forum.com/.