class FakeS3::CLI

Public Instance Methods

server() click to toggle source
# File lib/fakes3/cli.rb, line 19
def server
  store = nil
  if options[:root]
    root = File.expand_path(options[:root])
    # TODO Do some sanity checking here
    store = FileStore.new(root, options[:cachedstore])
  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]
    # In case the user has put a port on the 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] || '0.0.0.0'
  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 Swirl FakeS3 (ver. #{FakeS3::VERSION}) with #{root} on port #{options[:port]} with hostname #{hostname}"

  if (!options[:cachedstore])
    puts "Store cache is disabled. This option makes Fake S3 slow but allows for file-system manipulation"
  end

  server = FakeS3::Server.new(address,options[:port],store,hostname,ssl_cert_path,ssl_key_path)
  server.serve
end
version() click to toggle source
# File lib/fakes3/cli.rb, line 67
    def version
      puts <<"EOF"
======================
Swirl FakeS3 #{FakeS3::VERSION}

Swirl Networks, Inc
www.github.com/SwirlNetworks/fake-s3
EOF
    end