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
39
40
41
42
43
|
# File 'lib/private_gem_server/sanity.rb', line 5
def self.check!
fail! 'Please install git' if `which git` == ''
fail! 'Cannot run `gem`' if `which gem` == ''
begin
config = YAML.load_file ENV['GEM_SOURCES']
rescue
fail! 'Please supply a path to your gem sources YAML file in the GEM_SOURCES environment variable.'
end
fail! 'Config file includes no gems' unless Hash === config && Hash === config['gems'] && !config['gems'].empty?
store = ENV['GEM_STORE']
fail! 'Please set GEM_STORE to a readable/writable directory' unless store &&
File.directory?(store) &&
File.readable?(store) &&
File.writable?(store) &&
File.executable?(store)
log_path = ENV['GEM_SERVER_LOG']
if log_path
log_path = Pathname(log_path)
if log_path.exist?
fail! "Server log (#{log_path}) is not writable" unless log_path.writable?
else
log_path.parent.mkpath rescue fail! "Cannot create server log directory (#{log_path.parent})"
log_path.write '' rescue fail! "Cannot create server log (#{log_path})"
end
end
end
|