Browse files

swap out aws-s3 in favor of fog

Signed-off-by: Nick Quaranto <nick@quaran.to>
  • Loading branch information...
1 parent 47c2a46 commit 8aa2e0d50d7072e53ca0278e288754757ccc32ea @geemus geemus committed with qrush Jul 17, 2010
View
1 .gitignore
@@ -15,3 +15,4 @@ _site/
bin/
vendor/bundler_gems
*.gemspec
+*.rdb
View
1 Gemfile
@@ -5,6 +5,7 @@ gem "rack", "1.1.0"
gem "aws-s3", "0.6.2", :require => "aws/s3"
@geemus
geemus added a note Jul 27, 2010

Ideally this would also be removed (but this is where I ran in to trouble last time I rebased)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
gem "clearance", "0.9.0.rc5"
+gem "fog", "0.2.14"
gem "gchartrb", "0.8", :require => "google_chart"
gem "gravtastic", "2.1.3"
gem "high_voltage", "0.9.0"
View
8 config/initializers/s3.rb
@@ -1,6 +1,8 @@
if ENV['S3_KEY'] && ENV['S3_SECRET']
- AWS::S3::Base.establish_connection!(
- :access_key_id => ENV['S3_KEY'],
- :secret_access_key => ENV['S3_SECRET']
+ Fog.mock! unless Rails.env == 'production'
+ $fog = Fog::AWS::S3.new(
+ :aws_access_key_id => ENV['S3_KEY'],
+ :aws_secret_access_key => ENV['S3_SECRET']
)
+ $fog.directories.create(:key => "#{Rails.env.downcase}.s3.rubygems.org")
end
View
12 db/schema.rb
@@ -70,14 +70,6 @@
add_index "ownerships", ["rubygem_id"], :name => "index_ownerships_on_rubygem_id"
add_index "ownerships", ["user_id"], :name => "index_ownerships_on_user_id"
- create_table "requirements", :force => true do |t|
- t.integer "version_id"
- t.integer "dependency_id"
- end
-
- add_index "requirements", ["dependency_id"], :name => "index_requirements_on_dependency_id"
- add_index "requirements", ["version_id"], :name => "index_requirements_on_version_id"
-
create_table "rubyforgers", :force => true do |t|
t.string "email"
t.string "encrypted_password", :limit => 40
@@ -115,13 +107,13 @@
t.string "remember_token", :limit => 128
t.datetime "created_at"
t.datetime "updated_at"
- t.string "handle"
t.boolean "email_reset"
+ t.string "handle"
end
- add_index "users", ["confirmation_token", "id"], :name => "index_users_on_id_and_confirmation_token"
add_index "users", ["email"], :name => "index_users_on_email"
add_index "users", ["handle"], :name => "index_users_on_handle"
+ add_index "users", ["id", "confirmation_token"], :name => "index_users_on_id_and_confirmation_token"
add_index "users", ["id", "token"], :name => "index_users_on_id_and_token"
add_index "users", ["remember_token"], :name => "index_users_on_remember_token"
add_index "users", ["token"], :name => "index_users_on_token"
View
23 lib/vault.rb
@@ -1,15 +1,25 @@
module Vault
module S3
- OPTIONS = {:authenticated => false, :access => :public_read}
+ BUCKET = Rails.env.maintenance? ? "production" : Rails.env
+
+ def directory
+ $fog.directories.new(:key => "#{BUCKET}.s3.rubygems.org")
+ end
def write_gem
- cache_path = "gems/#{spec.original_name}.gem"
- VaultObject.store(cache_path, body.string, OPTIONS)
+ directory.files.create(
+ :body => body.string,
+ :key => "gems/#{spec.original_name}.gem"
+ )
quick_path = "quick/Marshal.4.8/#{spec.original_name}.gemspec.rz"
Pusher.indexer.abbreviate spec
Pusher.indexer.sanitize spec
- VaultObject.store(quick_path, Gem.deflate(Marshal.dump(spec)), OPTIONS)
+
+ directory.files.create(
+ :body => Gem.deflate(Marshal.dump(spec)),
+ :key => "quick/Marshal.4.8/#{spec.original_name}.gemspec.rz"
+ )
end
def upload(key, value)
@@ -19,7 +29,10 @@ def upload(key, value)
gzip.close
# For the life of me, I can't figure out how to pass a stream in here from a closed StringIO
- VaultObject.store(key, final.string, OPTIONS)
+ directory.files.create(
+ :body => final.string,
+ :key => key
+ )
end
end
View
10 lib/vault_object.rb
@@ -1,13 +1,9 @@
-class VaultObject < AWS::S3::S3Object
- BUCKET = Rails.env.maintenance? ? "production" : Rails.env
-
- set_current_bucket_to "#{BUCKET}.s3.rubygems.org"
-
+class VaultObject
def self.cf_url_for(path)
- "http://#{BUCKET}.cf.rubygems.org#{path}"
+ "http://#{Vault::S3::BUCKET}.cf.rubygems.org#{path}"
end
def self.s3_url_for(path)
- "http://#{BUCKET}.s3.rubygems.org#{path}"
+ "http://#{Vault::S3::BUCKET}.s3.rubygems.org#{path}"
end
end
View
4 test/unit/hostess_test.rb
@@ -11,10 +11,6 @@ def touch(path, local = true)
path = Pusher.server_path(path)
FileUtils.mkdir_p(File.dirname(path))
FileUtils.touch(path)
- else
- net_resp = FakeWeb::Responder.new(:get, "/", {}, 1).response
- s3_resp = AWS::S3::S3Object::Response.new(net_resp)
- stub(VaultObject).value(path, anything) { s3_resp }
end
end
View
BIN vendor/cache/aws-s3-0.6.2.gem
Binary file not shown.
View
BIN vendor/cache/excon-0.1.4.gem
Binary file not shown.
View
BIN vendor/cache/fog-0.2.14.gem
Binary file not shown.
View
BIN vendor/cache/formatador-0.0.15.gem
Binary file not shown.
View
BIN vendor/cache/net-ssh-2.0.23.gem
Binary file not shown.
View
BIN vendor/cache/ruby-hmac-0.4.0.gem
Binary file not shown.

0 comments on commit 8aa2e0d

Please sign in to comment.