Sha256: 4328eb41b3834f3ff0b63eb5e2a0704216ea651f0025cfe1a13a4479a7bf4d70
Contents?: true
Size: 1.62 KB
Versions: 1
Compression:
Stored size: 1.62 KB
Contents
require 'eff/downloader' require 'eff/template' require 'eff/package/semantic_version' require 'eff/verifier' module Eff class Package attr_accessor :name, :save_file, :version, :checksum, :hash_function def initialize(options = {}) @name = options[:name] @url_template = options[:url_template] @file_template = options[:file_template] self.version = options[:version] @checksum = options[:checksum] @hash_function = options[:hash_function] after_init_hook end def download downloader.get end def downloaded? downloader_success? end def url template_for(:url).result end def file_name template_for(:file).result end def save_file File.expand_path(file_name, Dir.pwd) end def version=(value) @version = SemanticVersion.new(value) clear_download! end def ==(other) (name == other.name) && (version == other.version) end def verified? verifiable? ? Verifier.check(save_file, checksum, hash_function) : false end def verifiable? checksum && hash_function end private def after_init_hook new_downloader end def downloader @downloader end def new_downloader @downloader = Eff::Downloader.new(url, save_file) end def downloader_success? downloader.success? end def clear_download! new_downloader if downloader end def template_for(sym) template = instance_variable_get("@#{sym}_template".to_sym) Eff::Template.new(template, version) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
eff-0.0.2 | lib/eff/package.rb |