Sha256: 3a9f81be3590a780c85f2a36e29b51aa2b2f3abfbacd1500abdae10f0f0ca16f

Contents?: true

Size: 911 Bytes

Versions: 1

Compression:

Stored size: 911 Bytes

Contents

module Heirloom

  class Directory

    attr_reader :local_build

    include Heirloom::Misc::Tmp

    def initialize(args)
      @config = args[:config]
      @exclude = args[:exclude]
      @path = args[:path]
      @logger = @config.logger
    end

    def build_artifact_from_directory
      @local_build = random_archive

      @logger.info "Building Heirloom '#{@local_build}' from '#{@path}'."
      @logger.info "Excluding #{@exclude.to_s}."
      @logger.info "Adding #{files_to_pack.to_s}."

      build_archive
    end

    private

    def build_archive
      command = "tar czf #{@local_build} #{files_to_pack.join(' ')}"
      @logger.info "Archiving with: `#{command}`"
      output = `#{command}`
      @logger.debug "Exited with status: '#{$?.exitstatus}' ouput: '#{output}'"
      $?.success?
    end

    def files_to_pack
      Dir.entries(@path) - ['.', '..'] - @exclude
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
heirloom-0.5.0rc2 lib/heirloom/directory/directory.rb