Sha256: a04cda4f61cf8f53a1ccc41af573b4a3a99afbe786729ff5230210ffc1a0aaa6

Contents?: true

Size: 695 Bytes

Versions: 2

Compression:

Stored size: 695 Bytes

Contents

require 'libarchive'

module Assetify

  class Pkg
    include Helpers
    attr_accessor :name, :url

    PATH = "/tmp/"

    def initialize(name, url)
      @name = name
      @pkgname = url.split("/").last
      @url = url
    end

    def path
      File.join(PATH, name)
    end

    def fullpath
      File.join(path, @pkgname)
    end

    def get(file)
      get_data(url) unless File.exists? File.join(PATH, @pkgname)
      data = nil
      Archive.read_open_filename(fullpath) do |ar|
        while entry = ar.next_header
          if entry.pathname =~ /#{file}/
            data = ar.read_data
            return data
          end
        end
      end
      data
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
assetify-0.2.2 lib/assetify/pkg.rb
assetify-0.2.1 lib/assetify/pkg.rb