class Geminabox::IncomingGem
def dest_filename
def dest_filename File.join(@root_path, "gems", name) end
def gem_data
def gem_data File.open(@tempfile.path, "rb") end
def get_name
def get_name filename = %W[#{spec.name} #{spec.version}] filename.push(spec.platform) if spec.platform && spec.platform != "ruby" filename.join("-") + ".gem" end
def hexdigest
def hexdigest @sha1 end
def initialize(gem_data, root_path = Geminabox.data)
def initialize(gem_data, root_path = Geminabox.data) unless gem_data.respond_to? :read raise ArgumentError, "Expected an instance of IO" end digest = Digest::SHA1.new @tempfile = Tempfile.new("gem", encoding: "binary", binmode: true) while data = gem_data.read(1024**2) @tempfile.write data digest << data end @tempfile.close @sha1 = digest.hexdigest @root_path = root_path end
def name
def name @name ||= get_name end
def spec
def spec @spec ||= Gem::Package.new(@tempfile.path).spec end
def valid?
def valid? spec && spec.name && spec.version rescue Gem::Package::Error false end