forked from rubygems/rubygems.org
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding the hostess so gem downloading can be tracked
- Loading branch information
Showing
9 changed files
with
112 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
$:.unshift File.expand_path(File.join(File.dirname(__FILE__))) | ||
|
||
require 'rubygems' | ||
require 'sinatra' | ||
require 'hostess' | ||
|
||
set :environment, :production | ||
run Gem::Hostess |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'rubygems' | ||
require 'sinatra' | ||
require 'haml' | ||
require 'gemcutter' | ||
|
||
module Gem | ||
class Hostess < Sinatra::Default | ||
set :app_file, __FILE__ | ||
|
||
get '/' do | ||
haml :index | ||
end | ||
|
||
get "/latest_specs.#{Gem.marshal_version}.gz" do | ||
send_file(current_path) | ||
end | ||
|
||
get "/quick/Marshal.#{Gem.marshal_version}/*.gemspec.rz" do | ||
content_type 'application/x-deflate' | ||
send_file(current_path) | ||
end | ||
|
||
get "/gems/*.gem" do | ||
content_type 'application/octet-stream' | ||
send_file(current_path) | ||
end | ||
|
||
def current_path | ||
Gemcutter.server_path(request.env["PATH_INFO"]) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
%h1 gems.gemcutter.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
require File.join(File.dirname(__FILE__), 'spec_helper') | ||
require 'apps/hostess/hostess' | ||
|
||
describe Gem::Hostess do | ||
def app | ||
Gem::Hostess.new | ||
end | ||
|
||
def touch(path) | ||
path = Gemcutter.server_path(path) | ||
FileUtils.touch(path) | ||
end | ||
|
||
def remove(path) | ||
path = Gemcutter.server_path(path) | ||
FileUtils.rm(path) if File.exists?(path) | ||
end | ||
|
||
it "should have a homepage" do | ||
get "/" | ||
last_response.status.should == 200 | ||
last_response.body.should =~ /gemcutter/ | ||
end | ||
|
||
it "should return latest specs" do | ||
file = "/latest_specs.4.8.gz" | ||
touch file | ||
get file | ||
last_response.status.should == 200 | ||
end | ||
|
||
it "should return quick gemspec" do | ||
file = "/quick/Marshal.4.8/test-0.0.0.gemspec.rz" | ||
touch file | ||
get file | ||
last_response.status.should == 200 | ||
last_response.content_type.should == "application/x-deflate" | ||
end | ||
|
||
it "should return gem" do | ||
file = "/gems/test-0.0.0.gem" | ||
touch file | ||
get file | ||
last_response.status.should == 200 | ||
end | ||
|
||
it "should not be able to find non existant gemspec" do | ||
file = "/quick/Marshal.4.8/test-0.0.0.gemspec.rz" | ||
remove file | ||
get file | ||
last_response.status.should == 404 | ||
end | ||
|
||
it "should not be able to find non existant gem" do | ||
file = "/gems/test-0.0.0.gem" | ||
remove file | ||
get file | ||
last_response.status.should == 404 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters