diff --git a/lib/common/common_helper.rb b/lib/common/common_helper.rb index 966b9c0e..f51a2517 100644 --- a/lib/common/common_helper.rb +++ b/lib/common/common_helper.rb @@ -49,14 +49,18 @@ end require 'environment' +def escape_glob(s) + s.gsub(/[\\\{\}\[\]\*\?]/) { |x| '\\' + x } +end + # TODO : add an exclude pattern ? def require_files_from_directory(absolute_dir_path, files_pattern = '*.rb') - files = Dir[File.join(absolute_dir_path, files_pattern)] + files = Dir[File.join(escape_glob(absolute_dir_path), files_pattern)] # Files in the root dir are loaded first, then those in the subdirectories files.sort_by { |file| [file.count('/'), file] }.each do |f| f = File.expand_path(f) - #puts "require #{f}" # Used for debug + puts "require #{f}" # Used for debug require f end end