lib/pdd/sources.rb in pdd-0.17.1 vs lib/pdd/sources.rb in pdd-0.17.2

- old
+ new

@@ -1,9 +1,8 @@ # encoding: utf-8 # -# Copyright (c) 2014-2016 TechnoPark Corp. -# Copyright (c) 2014-2016 Yegor Bugayenko +# Copyright (c) 2014-2017 Yegor Bugayenko # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the 'Software'), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell @@ -21,30 +20,28 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. require 'ptools' require 'pdd/source' -require 'rake/file_list' module PDD # Code base abstraction class Sources # Ctor. # +dir+:: Directory with source code files def initialize(dir, ptns = []) @dir = dir - @exclude = ptns + @exclude = ptns + ['.git/**/*'] end # Fetch all sources. def fetch - files = Rake::FileList.new(File.join(@dir, '**/*')) do |list| - @exclude.each do |ptn| - Rake::FileList.new(File.join(@dir, ptn)).each do |f| - list.exclude(f) - end + files = Dir.glob(File.join(@dir, '**/*'), File::FNM_DOTMATCH) + @exclude.each do |ptn| + Dir.glob(File.join(@dir, ptn), File::FNM_DOTMATCH) do |f| + files.delete_if { |i| i == f } end - end.to_a + end PDD.log.info "#{files.size} file(s) found" files.select { |f| !File.directory?(f) && !File.binary?(f) }.map do |file| VerboseSource.new( file, Source.new(file, file[@dir.length + 1, file.length])