Sha256: fac5a50f844c4e0ef8649f9a6a8f206f2176af5b328cdf3a796dd26bfb108c4e
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
require 'kvm/resource' require 'kvm/artifact' require 'open-uri' module KVM class Archive < FileResource BASE_DIR=File.expand_path('archives', KVM_DIR) attr_reader :filename def initialize(name, dist = "bin") @info = Artifact.parse_name(name, dist) @ext = Archive.project_extension(@info[:project]) @filename = Artifact.filename(@info, @ext) super(File.expand_path(Artifact.filename(@info, @ext), BASE_DIR)) end def generate! download end def download_url "http://downloads.#{@info[:project]}.kuali.org/#{@info[:version]}/#{@filename}" end def download FileUtils.mkdir_p BASE_DIR # this performs a redundant copy # TODO: make moar bettar # Thor get helper? open(download_url) do |src| File.open(File.join(BASE_DIR, @filename), "wb") do |dst| FileUtils.copy_stream(src, dst) end end #system("wget -P #{BASE_DIR} #{url}") || raise("Error downloading #{url}") end protected def self.project_extension(project) case project when 'kfs' 'zip' when 'rice' 'tar.gz' else 'tar.gz' end end def self.from_file(f) Archive.new(File.basename(f)) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kvm-0.0.1.pre | lib/kvm/archive.rb |