Class: Rip::RemoteGemPackage
- Inherits:
-
Package
- Object
- Package
- Rip::RemoteGemPackage
show all
- Defined in:
- lib/rip/packages/remote_gem_package.rb
Constant Summary
collapse
- @@remotes =
%w( gems.github.com gems.rubyforge.org )
- @@exists_cache =
{}
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!, #name
Methods included from Memoize
included, #memoize, #method_added
Constructor Details
This class inherits a constructor from Rip::Package
Instance Method Details
#actual_package ⇒ Object
60
61
62
|
# File 'lib/rip/packages/remote_gem_package.rb', line 60
def actual_package
Package.for(Dir[cache_path + '/*'].first)
end
|
#exists? ⇒ Boolean
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/rip/packages/remote_gem_package.rb', line 12
def exists?
return false unless source =~ /^[\w-]+$/
return true if @@exists_cache[source] || File.exists?(cache_path)
FileUtils.mkdir_p cache_path
Dir.chdir cache_path do
@@remotes.each do |remote|
ui.puts "Searching %s for %s..." % [ remote, source ]
source_flag = "--source=http://#{remote}/"
if rgem("fetch #{source} #{source_flag}") =~ /Downloaded (.+)/
@@exists_cache[source] = $1
return true
end
end
end
false
end
|
#fetch! ⇒ Object
45
46
|
# File 'lib/rip/packages/remote_gem_package.rb', line 45
def fetch!
end
|
#gembin ⇒ Object
64
65
66
|
# File 'lib/rip/packages/remote_gem_package.rb', line 64
def gembin
ENV['GEMBIN'] || 'gem'
end
|
41
42
43
|
# File 'lib/rip/packages/remote_gem_package.rb', line 41
def meta_package?
true
end
|
#rgem(command) ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/rip/packages/remote_gem_package.rb', line 33
def rgem(command)
Timeout.timeout(5) do
`#{gembin} #{command}`
end
rescue Timeout::Error
''
end
|
#unpack! ⇒ Object
48
49
50
51
52
53
|
# File 'lib/rip/packages/remote_gem_package.rb', line 48
def unpack!
installer = Installer.new
installer.install actual_package
installer.manager.sources[actual_package.name] = source
installer.manager.save
end
|
#version ⇒ Object
55
56
57
|
# File 'lib/rip/packages/remote_gem_package.rb', line 55
def version
actual_package ? actual_package.version : super
end
|