Method: Beaker::Options::Parser#file_list
- Defined in:
- lib/beaker/options/parser.rb
#file_list(paths) ⇒ Array
Generates a list of files based upon a given path or list of paths.
Looks recursively for .rb files in paths.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/beaker/options/parser.rb', line 68 def file_list(paths) files = [] if not paths.empty? paths.each do |root| if File.file?(root) files << root elsif File.directory?(root) #expand and explore discover_files = Dir.glob( File.join(root, "**/*.rb") ).select { |f| File.file?(f) } if discover_files.empty? parser_error "empty directory used as an option (#{root})!" end files += discover_files.sort_by {|file| [file.count("/"), file]} else #not a file, not a directory, not nothin' parser_error "#{root} used as a file option but is not a file or directory!" end end end if files.empty? parser_error "no .rb files found in #{paths.to_s}" end files end |