Sha256: 9647c316c603c3c10d42215254118cb3767cf00b35db896e8fdf358fc1a7092f

Contents?: true

Size: 892 Bytes

Versions: 3

Compression:

Stored size: 892 Bytes

Contents

require 'fileutils'
require 'pathname'
require 'tmpdir'
require 'logger'
require 'escoffier/compressible'

# Standard Mise en Place-able
module Smepable
  $LOG ||= Logger.new(STDOUT)
  include Compressible
  
  def prep_mise(input_entry, output_directory = Dir.mktmpdir, &block)
    # destination_dirname = File.dirname(output_directory)
    FileUtils.mkdir_p(output_directory) unless File.exist?(output_directory)
    $LOG.info "Copying #{input_entry} to #{output_directory}"
    verbose = $LOG.level <= Logger::DEBUG
    source = input_entry
    FileUtils.cp_r(source, output_directory, :verbose => verbose)
    $LOG.info "Unzipping #{output_directory}"
    unzip(output_directory, :recursive => true)
    
    if block
      begin
        yield output_directory
      ensure
        File.delete(output_directory)
      end

    else
      return output_directory
    end
    
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
escoffier-0.1.3 lib/escoffier/smepable.rb
escoffier-0.1.2 lib/escoffier/smepable.rb
escoffier-0.1.1 lib/escoffier/smepable.rb