Sha256: 417768875a2fe4585f268ed5f8d0eaef438be89e3de6737a4cab41f2ec73ea1d

Contents?: true

Size: 680 Bytes

Versions: 1

Compression:

Stored size: 680 Bytes

Contents

# This extension provides a simple means for 
# create file-system fixtures.

require 'erb'

# Set global temporary directory.
$tmpdir = 'tmp'

#
def copy_fixture(name, tmpdir=$tmpdir)
  FileUtils.mkdir(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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qed-2.4.0 lib/qed/extensions/filefixtures.rb