lib/slim-grunt-helpers/models/usemin.rb in slim-grunt-helpers-0.1.0 vs lib/slim-grunt-helpers/models/usemin.rb in slim-grunt-helpers-0.2.0

- old
+ new

@@ -1,5 +1,7 @@ +require 'pathname' + module SlimGruntHelpers module Models class Usemin @@ -26,15 +28,21 @@ def base_options BASE_OPTIONS end - def require_tree(root_path, pattern, options={}) - Dir[root_path.join(pattern)].reject do |file| + def require_tree(root_path, pattern, relative=false, options={}) + unless root_path.respond_to? :join + root_path = Pathname.new(root_path.to_s) + end + + Dir[root_path.join(pattern).to_s].reject do |file| File.directory? file end.each do |file| - file_name = file.to_s - file_name["#{ root_path }/"] = '' + file_name = file.to_s + real_root_path = root_path.to_s + real_root_path += '/' if relative + file_name[real_root_path] = '' self.require file_name, options end end \ No newline at end of file