Sha256: c033f8b3be85d32188b520cf8d28b7738b52bb06902ec15355aae23c543b3fdf

Contents?: true

Size: 907 Bytes

Versions: 1

Compression:

Stored size: 907 Bytes

Contents

require 'net/http'
require 'date'

module Rip
  class HTTPPackage < Package
    handles 'http://'

    def exists?
      code = Net::HTTP.get_response(URI.parse(source)).code
      code.to_i == 200
    end

    memoize :name
    def name
      source.split('/').last
    end

    def meta_package?
      true
    end

    def fetch!
      FileUtils.rm_rf cache_path
      FileUtils.mkdir_p cache_path
      File.open(File.join(cache_path, name), 'w') do |f|
        f.puts Net::HTTP.get(URI.parse(source))
      end
    end

    def unpack!
      installer = Installer.new
      installer.install actual_package
      installer.manager.sources[actual_package.name] = source
      installer.manager.save
    end

    def version
      actual_package ? actual_package.version : super
    end

    memoize :actual_package
    def actual_package
      Package.for(File.join(cache_path, name))
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rip-0.0.1 lib/rip/packages/http_package.rb