Class: Gemkeeper::CompactIndexServer::UploadHandler
- Inherits:
-
Object
- Object
- Gemkeeper::CompactIndexServer::UploadHandler
- Defined in:
- lib/gemkeeper/compact_index_server/upload_handler.rb
Overview
Handles POST /upload: reads the multipart gem file, parses its spec, and adds it to the index. Maps failures to compact-index HTTP responses.
Instance Method Summary collapse
- #call(req) ⇒ Object
-
#initialize(index) ⇒ UploadHandler
constructor
A new instance of UploadHandler.
Constructor Details
#initialize(index) ⇒ UploadHandler
Returns a new instance of UploadHandler.
11 12 13 |
# File 'lib/gemkeeper/compact_index_server/upload_handler.rb', line 11 def initialize(index) @index = index end |
Instance Method Details
#call(req) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gemkeeper/compact_index_server/upload_handler.rb', line 15 def call(req) upload = req.params["file"] return text(400, "Missing file parameter") unless upload text(201, "Uploaded #{add(upload[:tempfile].path)}") rescue Errno::EEXIST text(409, "Gem already exists") rescue Gem::Exception, Gem::Package::FormatError, Zlib::Error, TypeError, ArgumentError => error text(422, "Invalid gem: #{error.}") end |