class Geminabox::Server

def handle_incoming_gem(gem)

def handle_incoming_gem(gem)
  begin
    GemStore.create(gem, params[:overwrite])
  rescue GemStoreError => error
    error_response error.code, error.reason
  end
  begin
    Geminabox.on_gem_received.call(gem) if Geminabox.on_gem_received
  rescue
    # ignore errors which occur within the hook
  end
  if api_request?
    "Gem #{gem.name} received and indexed."
  else
    redirect url("/")
  end
end