diff options
| author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-20 08:39:12 +0000 |
|---|---|---|
| committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-20 08:39:12 +0000 |
| commit | dcf06bd39ea72acbc312758e2df764c4b982b40c (patch) | |
| tree | f6d367888b42848fd6a660fad57fa2020e38c097 /lib/rubygems/server.rb | |
| parent | eb954f44e53ba18225a0e906891c47373ce0d651 (diff) | |
| download | ruby-dcf06bd39ea72acbc312758e2df764c4b982b40c.tar.gz ruby-dcf06bd39ea72acbc312758e2df764c4b982b40c.tar.xz ruby-dcf06bd39ea72acbc312758e2df764c4b982b40c.zip | |
Import RubyGems 1.0.0, r1575
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/server.rb')
| -rw-r--r-- | lib/rubygems/server.rb | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/rubygems/server.rb b/lib/rubygems/server.rb index 212ccc5f7..ed957dd38 100644 --- a/lib/rubygems/server.rb +++ b/lib/rubygems/server.rb @@ -368,19 +368,34 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; } when '/quick/index.rz' then index = @source_index.map { |name,_| name }.join("\n") res.body << Zlib::Deflate.deflate(index) - when %r|^/quick/(.*)-([0-9.]+)\.gemspec(\.marshal)?\.rz$| then - specs = @source_index.search $1, $2 + when %r|^/quick/(Marshal.#{Regexp.escape Gem.marshal_version}/)?(.*?)-([0-9.]+)(-.*?)?\.gemspec\.rz$| then + dep = Gem::Dependency.new $2, $3 + specs = @source_index.search dep + + selector = [$2, $3, $4].map { |s| s.inspect }.join ' ' + + platform = if $4 then + Gem::Platform.new $4.sub(/^-/, '') + else + Gem::Platform::RUBY + end + + specs = specs.select { |s| s.platform == platform } + if specs.empty? then res.status = 404 + res.body = "No gems found matching #{selector}" elsif specs.length > 1 then res.status = 500 - elsif $3 # marshal quickindex instead of YAML + res.body = "Multiple gems found matching #{selector}" + elsif $1 then # marshal quickindex instead of YAML res.body << Zlib::Deflate.deflate(Marshal.dump(specs.first)) else # deprecated YAML format res.body << Zlib::Deflate.deflate(specs.first.to_yaml) end else res.status = 404 + res.body = "#{req.request_uri} not found" end end |
