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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/fakes3/cli.rb', line 19
def server
store = nil
if options[:root]
root = File.expand_path(options[:root])
store = FileStore.new(root, !!options[:quiet])
end
if store.nil?
abort "You must specify a root to use a file store (the current default)"
end
hostname = 's3.amazonaws.com'
if options[:hostname]
hostname = options[:hostname]
if hostname =~ /:(\d+)/
hostname = hostname.split(":")[0]
end
end
if options[:limit]
begin
store.rate_limit = options[:limit]
rescue
abort $!.message
end
end
address = options[:address]
ssl_cert_path = options[:sslcert]
ssl_key_path = options[:sslkey]
if (ssl_cert_path.nil? && !ssl_key_path.nil?) || (!ssl_cert_path.nil? && ssl_key_path.nil?)
abort "If you specify an SSL certificate you must also specify an SSL certificate key"
end
puts "Loading FakeS3 with #{root} on port #{options[:port]} with hostname #{hostname}" unless options[:quiet]
server = FakeS3::Server.new(address,options[:port],store,hostname,ssl_cert_path,ssl_key_path, quiet: !!options[:quiet])
server.serve
end
|