Class: Resat::FileSet
- Inherits:
-
Array
- Object
- Array
- Resat::FileSet
- Defined in:
- lib/file_set.rb
Constant Summary collapse
- IGNORED_FOLDERS =
Folders that won’t be scanned for files
%w{ . .. .svn .git }
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(dir, extensions) ⇒ FileSet
constructor
Initialize with all file names found in ‘dir’ and its sub-directories with given file extensions.
Constructor Details
#initialize(dir, extensions) ⇒ FileSet
Initialize with all file names found in ‘dir’ and its sub-directories with given file extensions
13 14 15 16 |
# File 'lib/file_set.rb', line 13 def initialize(dir, extensions) super(0) concat(FileSet.gather_files(dir, extensions)) end |
Class Method Details
.gather_files(dir, extensions) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/file_set.rb', line 18 def self.gather_files(dir, extensions) files = Array.new Dir.foreach(dir) do |filename| if File.directory?(filename) unless IGNORED_FOLDERS.include?(filename) files.concat(FileSet.gather_files(filename, extensions)) end elsif extensions.include?(File.extname(filename)) files << File.join(dir, filename) end end files end |