Class: Rip::HTTPPackage

Inherits:
Package show all
Defined in:
lib/rip/packages/http_package.rb

Instance Attribute Summary

Attributes inherited from Package

#files, #source

Instance Method Summary collapse

Methods inherited from Package

#cache_name, #cache_path, #dependencies, #dependencies!, #fetch, #files!, for, handles, #initialize, #installed?, #packages_path, #run_hook, #to_s, #ui, #unpack

Methods included from PackageAPI

#cached?, #dependencies!, #files!

Methods included from Memoize

included, #memoize, #method_added

Constructor Details

This class inherits a constructor from Rip::Package

Instance Method Details

#actual_packageObject



41
42
43
# File 'lib/rip/packages/http_package.rb', line 41

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

#exists?Boolean

Returns:

  • (Boolean)


8
9
10
11
# File 'lib/rip/packages/http_package.rb', line 8

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

#fetch!Object



22
23
24
25
26
27
28
# File 'lib/rip/packages/http_package.rb', line 22

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

#meta_package?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/rip/packages/http_package.rb', line 18

def meta_package?
  true
end

#nameObject



14
15
16
# File 'lib/rip/packages/http_package.rb', line 14

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

#unpack!Object



30
31
32
33
34
35
# File 'lib/rip/packages/http_package.rb', line 30

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

#versionObject



37
38
39
# File 'lib/rip/packages/http_package.rb', line 37

def version
  actual_package ? actual_package.version : super
end