If I wanted to get all the CSS and JavaScript files
Dir.glob("dir/**/*.{css,js})
gives me stuff that I don't want if there is a folder called stupidfolder.js . I would just change the name of the folder, but I cannot.
stupidfolder.js
You cannot do this with Dir.glob . You must explicitly reject these entries.
Dir.glob
only_files = Dir.glob('*').reject do |path| File.directory?(path) end
You can do it with Dir.entries
Dir.entries
Dir.entries('../directoryname').reject { |f| File.directory?(f) }
This may be an exaggeration for your problem, but rake defines the FileList class. You can replace Dir.glob with this class:
rake
FileList
require 'rake' filelist = FileList.new("dir/**/*.{css,js}") filelist.exclude('**/stupidfolder.js') filelist.each do |file| #... end