Sha256: 42d29163cf49bd64fe948bbcb8f5257b0cbd26a02e246da71ab0e25fa6d439b7
Contents?: true
Size: 905 Bytes
Versions: 19
Compression:
Stored size: 905 Bytes
Contents
module QED # This extension provides a simple means for creatind file-system fixtures. # Include this in your applique, to have a module FileFixtures # def self.included(base) require 'erb' end # def copy_fixture(name, tmpdir=nil) tmpdir ||= 'tmp' # self.tmpdir FileUtils.mkdir(tmpdir) unless File.directory?(tmpdir) srcdir = File.join(demo_directory, 'fixtures', name) paths = Dir.glob(File.join(srcdir, '**', '*'), File::FNM_DOTMATCH) paths.each do |path| basename = File.basename(path) next if basename == '.' next if basename == '..' dest = File.join(tmpdir, path.sub(srcdir+'/', '')) if File.directory?(path) FileUtils.mkdir(dest) else text = ERB.new(File.read(path)).result File.open(dest, 'w'){ |f| f << text } end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems