module FileHelpers
Public Instance Methods
copy_file(source, target)
click to toggle source
# File lib/SimpliTest/helpers/file.rb, line 8 def copy_file(source, target) FileUtils.cp(source, target) end
copy_file_with_replacement_args(template_name, target_location, args={})
click to toggle source
# File lib/SimpliTest/helpers/file.rb, line 27 def copy_file_with_replacement_args(template_name, target_location, args={}) file = File.open(template_path_to(template_name)) content = file.read target_location = File.join(@pwd, template_name) unless target_location args.each do |key, value| content = content.gsub(/#{key}/,value ) end File.open(target_location, 'w') { |f| f.write(content) } end
copy_folder(source, target)
click to toggle source
# File lib/SimpliTest/helpers/file.rb, line 12 def copy_folder(source, target) FileUtils.copy_entry(source, target) end
make_directory(dirname)
click to toggle source
# File lib/SimpliTest/helpers/file.rb, line 4 def make_directory(dirname) FileUtils.mkdir_p(dirname) end
make_subdirectories_in(directory, *subdirectories)
click to toggle source
# File lib/SimpliTest/helpers/file.rb, line 16 def make_subdirectories_in(directory, *subdirectories) subdirectories.each do |subdir| FileUtils.mkdir_p(File.join(directory, subdir)) end end
template_path_to(*args)
click to toggle source
# File lib/SimpliTest/helpers/file.rb, line 22 def template_path_to(*args) relative_path = args.join(File::Separator) File.join(SimpliTest.path_to_templates_dir, relative_path) end