lib/retrospec/plugins/v1/module_helpers.rb in retrospec-0.6.0 vs lib/retrospec/plugins/v1/module_helpers.rb in retrospec-0.6.1

- old
+ new

@@ -187,25 +187,24 @@ dest_path = File.expand_path(path) safe_create_file(dest_path, content, sync_file) end end - # creates any file that is contained in the templates/modules_files directory structure + # creates any file that is contained in the templates_dir directory structure # loops through the directory looking for erb files or other files. # strips the erb extension and renders the template to the current module path # filenames must named how they would appear in the normal module path. The directory # structure where the file is contained # @param [String] template directory of where to find templates # @param [String] module_path - path to the module # @param [String] spec_object - the context that is used for template rendering # @param [String] filter - a regex string used to filter out files - def safe_create_module_files(template_dir, module_path, spec_object, filter = nil) - dir = File.join(template_dir,'module_files') - templates = Find.find(dir).sort + def safe_create_directory_files(template_dir, module_path, spec_object, filter = nil) + templates = Find.find(template_dir).sort templates.each do |template| next if template =~ filter - dest = template.gsub(File.join(template_dir,'module_files'), module_path) + dest = template.gsub(template_dir, module_path) if File.symlink?(template) safe_create_symlink(template, dest) elsif File.directory?(template) safe_mkdir(dest) else @@ -221,9 +220,25 @@ else safe_copy_file(template, dest, sync_file) end end end + end + + + + # creates any file that is contained in the templates/modules_files directory structure + # loops through the directory looking for erb files or other files. + # strips the erb extension and renders the template to the current module path + # filenames must named how they would appear in the normal module path. The directory + # structure where the file is contained + # @param [String] template directory of where to find templates + # @param [String] module_path - path to the module + # @param [String] spec_object - the context that is used for template rendering + # @param [String] filter - a regex string used to filter out files + def safe_create_module_files(template_dir, module_path, spec_object, filter = nil) + dir = File.join(template_dir,'module_files') + safe_create_directory_files(dir, module_path, spec_object, filter = nil) end end end end end