Class: RubyLint::FileList
- Inherits:
-
Object
- Object
- RubyLint::FileList
- Defined in:
- lib/ruby-lint/file_list.rb
Overview
The FileList class acts as a small wrapper around Dir.glob
and is mainly
used to turn a list of filenames/directory names into a list of just file
names (excluding ones that don’t exist).
Instance Method Summary collapse
-
#glob_files(directory) ⇒ Array
Returns a list of Ruby files in the given directory.
-
#process(files) ⇒ Array
Instance Method Details
#glob_files(directory) ⇒ Array
Returns a list of Ruby files in the given directory. This list includes deeply nested files.
39 40 41 |
# File 'lib/ruby-lint/file_list.rb', line 39 def glob_files(directory) return Dir.glob(File.join(directory, '**/*.rb')) end |
#process(files) ⇒ Array
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ruby-lint/file_list.rb', line 13 def process(files) existing = [] files.each do |file| file = File.(file) if File.file?(file) existing << file elsif File.directory?(file) existing = existing | glob_files(file) else raise Errno::ENOENT, file end end return existing end |