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

Version Path
qed-2.9.2 lib/qed/helpers/file_fixtures.rb
qed-2.9.1 lib/qed/helpers/file_fixtures.rb
qed-2.9.0 lib/qed/helpers/file_fixtures.rb
qed-2.8.8 lib/qed/helpers/file_fixtures.rb
qed-2.8.7 lib/qed/helpers/file_fixtures.rb
qed-2.8.6 lib/qed/helpers/file_fixtures.rb
qed-2.8.5 lib/qed/helpers/file_fixtures.rb
qed-2.8.4 lib/qed/helpers/file_fixtures.rb
qed-2.8.3 lib/qed/helpers/file_fixtures.rb
qed-2.8.2 lib/qed/helpers/file_fixtures.rb
qed-2.8.1 lib/qed/helpers/file_fixtures.rb
qed-2.8.0 lib/qed/helpers/file_fixtures.rb
qed-2.7.0 lib/qed/helpers/file_fixtures.rb
qed-2.6.3 lib/qed/helpers/file_fixtures.rb
qed-2.6.2 lib/qed/helpers/file_fixtures.rb
qed-2.6.1 lib/qed/helpers/file_fixtures.rb
qed-2.6.0 lib/qed/helpers/file_fixtures.rb
qed-2.5.1 lib/qed/helpers/file_fixtures.rb
qed-2.5.0 lib/qed/helpers/file_fixtures.rb