Class: Rip::GemPackage
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, #installed?, #packages_path, #run_hook, #to_s, #ui, #unpack
Methods included from PackageAPI
#cached?, #dependencies!, #files!, #meta_package?
Methods included from Memoize
included, #memoize, #method_added
Constructor Details
#initialize(source, *args) ⇒ GemPackage
Returns a new instance of GemPackage.
5
6
7
8
|
# File 'lib/rip/packages/gem_package.rb', line 5
def initialize(source, *args)
super
@source = File.expand_path(source.strip.chomp)
end
|
Instance Method Details
#cache_file ⇒ Object
18
19
20
|
# File 'lib/rip/packages/gem_package.rb', line 18
def cache_file
"#{cache_path}.gem"
end
|
#exists? ⇒ Boolean
22
23
24
25
26
27
28
|
# File 'lib/rip/packages/gem_package.rb', line 22
def exists?
if `which #{gembin}`.strip.empty?
ui.abort "you don't have #{gembin} installed"
end
File.exists?(source)
end
|
#fetch! ⇒ Object
30
31
32
|
# File 'lib/rip/packages/gem_package.rb', line 30
def fetch!
FileUtils.cp File.expand_path(source), cache_file
end
|
#gembin ⇒ Object
44
45
46
|
# File 'lib/rip/packages/gem_package.rb', line 44
def gembin
ENV['GEMBIN'] || 'gem'
end
|
39
40
41
42
|
# File 'lib/rip/packages/gem_package.rb', line 39
def metadata
parts = source.split('/').last.chomp('.gem').split('-')
{ :name => parts[0...-1].join('-'), :version => parts[-1] }
end
|
#name ⇒ Object
10
11
12
|
# File 'lib/rip/packages/gem_package.rb', line 10
def name
metadata[:name]
end
|
#unpack! ⇒ Object
34
35
36
|
# File 'lib/rip/packages/gem_package.rb', line 34
def unpack!
system "'#{gembin}' unpack '#{cache_file}' --target='#{packages_path}' > /dev/null"
end
|
#version ⇒ Object
14
15
16
|
# File 'lib/rip/packages/gem_package.rb', line 14
def version
metadata[:version]
end
|