Sha256: 8a80f11b083f4a21650185947427d3e077ff33d0f97585c4f593794ea377798a

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

# encoding: UTF-8

module Gjp
  # generates file archives that accompany spec files
  class Archiver
    include Logger

    def initialize(project)
      @project = project
    end

    # generates an archive for the project's kit package based on
    # its file list
    def archive_kit
      list_file = File.join(@project.full_path, "file_lists/kit")
      if not File.exist? list_file
        return false
      end
      destination_file = File.join(@project.full_path, "archives/#{@project.name}-kit.tar.xz")

      @project.from_directory "kit" do
        archive list_file, destination_file
      end
      
      true
    end

    # generates an archive for a project's source package based on
    # its file list
    def archive_src(name)
      list_file = File.join(@project.full_path, "file_lists/#{name}_input")
      if not File.exist? list_file
        return false
      end
      destination_file = File.join(@project.full_path, "archives/#{@project.name}-#{name}.tar.xz")

      @project.from_directory File.join("src", name) do
        archive list_file, destination_file
      end

      true
    end

    # compresses files specified in the list file to the destination file
    def archive(list_file, destination_file)
      `tar --files-from=#{list_file} -cJf #{destination_file}`
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gjp-0.13.1 lib/gjp/archiver.rb