Class: Rip::FilePackage
Instance Attribute Summary
Attributes inherited from Package
#files, #source
Instance Method Summary
collapse
Methods inherited from Package
#cache_name, #cache_path, #dependencies, #dependencies!, #fetch, for, handles, #installed?, #packages_path, #run_hook, #to_s, #ui, #unpack
Methods included from PackageAPI
#cached?, #dependencies!, #meta_package?
Methods included from Memoize
included, #memoize, #method_added
Constructor Details
#initialize(source, *args) ⇒ FilePackage
Returns a new instance of FilePackage.
9
10
11
12
|
# File 'lib/rip/packages/file_package.rb', line 9
def initialize(source, *args)
super
@source = File.expand_path(source)
end
|
Instance Method Details
#exists? ⇒ Boolean
14
15
16
|
# File 'lib/rip/packages/file_package.rb', line 14
def exists?
File.file? source
end
|
#fetch! ⇒ Object
31
32
33
34
35
|
# File 'lib/rip/packages/file_package.rb', line 31
def fetch!
FileUtils.rm_rf cache_path
FileUtils.mkdir_p cache_path
FileUtils.cp source, File.join(cache_path, name)
end
|
#files! ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/rip/packages/file_package.rb', line 37
def files!
fetch
Dir.chdir cache_path do
file = File.readlines(source)[0...5].detect do |line|
line =~ /^# ?file:(.+)/
end
if file
dir = File.dirname($1)
file = File.basename($1)
[ File.join(Rip::Env.active_dir, dir, file) ]
else
[ File.join(Rip::Env.active_dir, 'lib', name) ]
end
end
end
|
#name ⇒ Object
19
20
21
|
# File 'lib/rip/packages/file_package.rb', line 19
def name
File.basename(source)
end
|
#unpack! ⇒ Object
55
56
57
58
59
60
61
62
|
# File 'lib/rip/packages/file_package.rb', line 55
def unpack!
Dir.chdir cache_path do
files.each do |file|
FileUtils.mkdir_p File.dirname(file)
FileUtils.cp File.join(cache_path, name), file
end
end
end
|
#version ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/rip/packages/file_package.rb', line 23
def version
if name.match(/-((?:\d+\.?)+\d+)\.rb$/)
$1
else
Date.today.to_s
end
end
|