/
gem.rb
38 lines (32 loc) · 853 Bytes
/
gem.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'fpm/cookery/source_handler/template'
require 'fpm/cookery/log'
module FPM
module Cookery
class SourceHandler
class Gem < FPM::Cookery::SourceHandler::Template
NAME = :gem
CHECKSUM = true
def fetch
name = options[:name]
version = options[:version]
if local_path.exist?
Log.info "Using cached file #{local_path}"
else
Dir.chdir(cachedir) do
gem(name, version, url) unless local_path.exist?
end
end
local_path
end
def extract
FileUtils.cp(local_path, '.')
Dir.pwd
end
private
def gem(name, version, source)
safesystem('gem', 'fetch', name, '-v', version, '--source', source)
end
end
end
end
end