diff --git a/rubygems_proxy.rb b/rubygems_proxy.rb index 5e77d1e..5ffa68a 100644 --- a/rubygems_proxy.rb +++ b/rubygems_proxy.rb @@ -23,6 +23,8 @@ def run case env["PATH_INFO"] when "/" [200, {"Content-Type" => "text/html"}, [erb(:index)]] + when '/api/v1/dependencies' + [200, {"Content-Type" => "application/octet-stream"}, [contents]] else [200, {"Content-Type" => "application/octet-stream"}, [contents]] end @@ -119,16 +121,23 @@ def specs? env["PATH_INFO"] =~ /specs\..+\.gz$/ end + def dependencies? + env["PATH_INFO"] =~ /dependencies/ + end + def filepath if specs? File.join(root_dir, env["PATH_INFO"]) - else - File.join(cache_dir, env["PATH_INFO"]) + else dependencies? ? + File.join(cache_dir, env["REQUEST_URI"]) : + File.join(cache_dir, env["PATH_INFO"]) end end def url - File.join("http://rubygems.org", env["PATH_INFO"]) + dependencies? ? + File.join("http://rubygems.org", env["REQUEST_URI"]) : + File.join("http://rubygems.org", env["PATH_INFO"]) end def update_specs