Skip to content
This repository was archived by the owner on Sep 25, 2020. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions rubygems_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down