Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleanup for vault and gemcutter

  • Loading branch information...
commit 96d85053b215750d6f030b124c140dd8d455ddf5 1 parent a08661c
@qrush qrush authored
View
6 app/controllers/sessions_controller.rb
@@ -1,6 +0,0 @@
-class SessionsController < Clearance::SessionsController
- private
- def url_after_create
- dashboard_url
- end
-end
View
5 config/environment.rb
@@ -10,10 +10,11 @@
DO_NOT_REPLY = "donotreply@gemcutter.org"
-require 'lib/indexer'
-require 'lib/core_ext/string'
+require 'lib/rubygems/format'
+require 'lib/rubygems/indexer'
require 'rdoc/markup/simple_markup'
require 'rdoc/markup/simple_markup/to_html'
+require 'clearance/sessions_controller'
Gem.configuration.verbose = false
ActiveRecord::Base.include_root_in_json = false
View
11 config/initializers/clearance.rb
@@ -0,0 +1,11 @@
+require 'clearance/confirmations_controller'
+require 'clearance/passwords_controller'
+require 'clearance/sessions_controller'
+require 'clearance/users_controller'
+
+class Clearance::SessionsController
+ private
+ def url_after_create
+ dashboard_url
+ end
+end
View
0  lib/core_ext/string.rb → config/initializers/core_ext.rb
File renamed without changes
View
2  config/routes.rb
@@ -41,7 +41,5 @@
:action => 'destroy',
:method => :delete
- map.resource :session, :only => [:new, :create, :destroy]
-
map.root :controller => "home", :action => "index"
end
View
6 cucumber.yml
@@ -1,3 +1,3 @@
-default: features -t ~wip
-wip: features -t wip
-all: features
+default: features -t ~wip -f progress
+wip: features -t wip -f progress
+all: features -f progress
View
32 lib/gemcutter.rb
@@ -81,8 +81,34 @@ def inspect
end
def self.indexer
- indexer = Gem::Indexer.new(Gemcutter.server_path, :build_legacy => false)
- def indexer.say(message) end
- indexer
+ @indexer ||=
+ begin
+ indexer = Gem::Indexer.new(Gemcutter.server_path, :build_legacy => false)
+ def indexer.say(message) end
+ indexer
+ end
+ end
+
+ def specs_index
+ Version.with_indexed.map(&:to_index)
+ end
+
+ def latest_index
+ Version.latest.release.map(&:to_index)
+ end
+
+ def prerelease_index
+ Version.prerelease.map(&:to_index)
+ end
+
+ def perform
+ Version.update_all({:indexed => true}, {:id => self.version_id})
+ update_index
+ end
+
+ def update_index
+ upload("specs.4.8.gz", specs_index)
+ upload("latest_specs.4.8.gz", latest_index)
+ upload("prerelease_specs.4.8.gz", prerelease_index)
end
end
View
71 lib/indexer.rb
@@ -1,71 +0,0 @@
-require 'rubygems/indexer'
-
-module Gem
- class Indexer
- def update_specs_index(index, source, dest)
- specs_index = Marshal.load Gem.read_binary(source)
-
- index.each do |_, spec|
- platform = spec.original_platform
- platform = Gem::Platform::RUBY if platform.nil? or platform.empty?
- specs_index << [spec.name, spec.version, platform]
- end
-
- specs_index = compact_specs specs_index.uniq
-
- open dest, 'wb' do |io|
- Marshal.dump specs_index, io
- end
- end
-
- def update_index(source_index = nil)
- make_temp_directories
-
- #specs_mtime = File.mtime(@dest_specs_index)
- #newest_mtime = Time.at 0
-
- #updated_gems = gem_file_list.select do |gem|
- #gem_mtime = File.mtime(gem)
- #newest_mtime = gem_mtime if gem_mtime > newest_mtime
- #gem_mtime >= specs_mtime
- #end
-
- #if updated_gems.empty? then
- #say 'No new gems'
- #terminate_interaction 0
- #end
-
- newest_mtime = Time.now
- index = source_index || Marshal.load(File.open(File.join(@dest_directory, "source_index")))
-
- Gem.time 'Updated indexes' do
- update_specs_index index, @dest_specs_index, @specs_index
- update_specs_index index, @dest_latest_specs_index, @latest_specs_index
- update_specs_index(index.prerelease_gems, @dest_prerelease_specs_index,
- @prerelease_specs_index)
- end
-
- compress_indicies
-
- files = []
- files << @specs_index
- files << "#{@specs_index}.gz"
- files << @latest_specs_index
- files << "#{@latest_specs_index}.gz"
- files << @prerelease_specs_index
- files << "#{@prerelease_specs_index}.gz"
-
- files = files.map do |path|
- path.sub @directory, ''
- end
-
- files.each do |file|
- src_name = File.join @directory, file
- dst_name = File.join @dest_directory, File.dirname(file)
-
- FileUtils.mv src_name, dst_name, :force => true
- File.utime newest_mtime, newest_mtime, dst_name
- end
- end
- end
-end
View
4 lib/tasks/cucumber.rake
@@ -10,13 +10,13 @@ begin
namespace :cucumber do
Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
t.fork = true # You may get faster startup if you set this to false
- t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
+ t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'progress'}"
t.binary = vendored_cucumber_binary
end
Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
t.fork = true # You may get faster startup if you set this to false
- t.cucumber_opts = "--color --tags @wip:2 --wip --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
+ t.cucumber_opts = "--color --tags @wip:2 --wip --format #{ENV['CUCUMBER_FORMAT'] || 'progress'}"
t.binary = vendored_cucumber_binary
end
View
58 lib/vault.rb
@@ -2,39 +2,16 @@ module Vault
module S3
OPTIONS = {:authenticated => false, :access => :public_read}
- def perform
- Version.update_all({:indexed => true}, {:id => self.version_id})
- update_index
- end
-
- def specs_index
- Version.with_indexed.map(&:to_index)
- end
-
- def latest_index
- Version.latest.release.map(&:to_index)
- end
-
- def prerelease_index
- Version.prerelease.map(&:to_index)
- end
-
def write_gem
cache_path = "gems/#{spec.original_name}.gem"
VaultObject.store(cache_path, body.string, OPTIONS)
- quick_path = "quick/Marshal.#{Gem.marshal_version}/#{spec.original_name}.gemspec.rz"
+ quick_path = "quick/Marshal.4.8/#{spec.original_name}.gemspec.rz"
Gemcutter.indexer.abbreviate spec
Gemcutter.indexer.sanitize spec
VaultObject.store(quick_path, Gem.deflate(Marshal.dump(spec)), OPTIONS)
end
- def update_index
- upload("specs.#{Gem.marshal_version}.gz", specs_index)
- upload("latest_specs.#{Gem.marshal_version}.gz", latest_index)
- upload("prerelease_specs.#{Gem.marshal_version}.gz", prerelease_index)
- end
-
def upload(key, value)
final = StringIO.new
gzip = Zlib::GzipWriter.new(final)
@@ -47,23 +24,6 @@ def upload(key, value)
end
module FS
- def perform
- write_gem
- update_index
- end
-
- def source_path
- Gemcutter.server_path("source_index")
- end
-
- def source_index
- if File.exists?(source_path)
- @source_index ||= Marshal.load(Gem.inflate(File.read(source_path)))
- else
- @source_index ||= Gem::SourceIndex.new
- end
- end
-
def write_gem
cache_path = Gemcutter.server_path('gems', "#{spec.original_name}.gem")
File.open(cache_path, "wb") do |f|
@@ -71,7 +31,7 @@ def write_gem
end
File.chmod 0644, cache_path
- quick_path = Gemcutter.server_path("quick", "Marshal.#{Gem.marshal_version}", "#{spec.original_name}.gemspec.rz")
+ quick_path = Gemcutter.server_path("quick", "Marshal.4.8", "#{spec.original_name}.gemspec.rz")
FileUtils.mkdir_p(File.dirname(quick_path))
Gemcutter.indexer.abbreviate spec
@@ -82,13 +42,15 @@ def write_gem
File.chmod 0644, quick_path
end
- def update_index
- source_index.add_spec spec, spec.original_name
- File.open(source_path, "wb") do |f|
- f.write Gem.deflate(Marshal.dump(source_index))
- end
+ def upload(key, value)
+ final = StringIO.new
+ gzip = Zlib::GzipWriter.new(final)
+ gzip.write(Marshal.dump(value))
+ gzip.close
- Gemcutter.indexer.update_index(source_index)
+ File.open(Gemcutter.server_path(key), "wb") do |f|
+ f.write final.string
+ end
end
end
end
View
1  server/index.html
@@ -1 +0,0 @@
-gemcutter gems
View
3  test/test_helper.rb
@@ -5,8 +5,6 @@
FakeWeb.allow_net_connect = false
set :environment, :test
-Gemcutter.indexer.generate_index
-
Shoulda.autoload_macros(Rails.root, "vendor/bundler_gems/gems/*")
class ActiveSupport::TestCase
@@ -39,7 +37,6 @@ def regenerate_index
server/quick
server/specifications
server/source_index].map { |d| Dir[d] })
- Gemcutter.indexer.generate_index
end
def create_gem(owner, opts = {})
View
8 test/unit/gemcutter_test.rb
@@ -15,14 +15,6 @@ class GemcutterTest < ActiveSupport::TestCase
end
end
- should "generate a new indexer" do
- @indexer = "indexer"
- mock(Gem::Indexer).new(Gemcutter.server_path, :build_legacy => false) { @indexer }
- assert_equal @indexer, Gemcutter.indexer
- assert @indexer.respond_to?(:say)
- assert_nil @indexer.say("Should be quiet")
- end
-
context "creating a new gemcutter" do
setup do
@user = Factory(:email_confirmed_user)
View
48 test/unit/indexer_test.rb
@@ -1,48 +0,0 @@
-require File.dirname(__FILE__) + '/../test_helper'
-
-class IndexerTest < ActiveSupport::TestCase
- context "when generating the index" do
- setup do
- @gem = "gem"
- @tmpdir = "tmpdir"
- @time = Time.now
- regenerate_index
- end
-
- should "index properly" do
- mock(Dir).tmpdir { @tmpdir }
-
- mock.proxy(Gem::Indexer).new(Gemcutter.server_path, :build_legacy => false) do |indexer|
- mock(indexer).make_temp_directories
- #mock(indexer).gem_file_list { [@gem] }
- stub(indexer).update_specs_index
- mock(indexer).compress_indicies
- end
-
- # Loading the cached source index
- source_index_data = "source index data"
- source_index = "source index"
- stub(source_index).prerelease_gems
- mock(File).open(Gemcutter.server_path("source_index")) { source_index_data }
- mock(Marshal).load(source_index_data) { source_index }
-
- # Moving the compressed specs into place
- ["/specs.4.8",
- "/specs.4.8.gz",
- "/latest_specs.4.8",
- "/latest_specs.4.8.gz",
- "/prerelease_specs.4.8",
- "/prerelease_specs.4.8.gz"].each do |spec|
-
- mock(FileUtils).mv(File.join(@tmpdir, "gem_generate_index_#{$$}", spec),
- Gemcutter.server_path + "/",
- :force => true)
-
- # TODO: we need to bring in TIMECOP for this
- mock(File).utime(anything, anything, Gemcutter.server_path + "/")
- end
-
- Gemcutter.indexer.update_index
- end
- end
-end
View
94 test/unit/vault_test.rb
@@ -1,94 +0,0 @@
-require File.dirname(__FILE__) + '/../test_helper'
-
-class VaultTest < ActiveSupport::TestCase
- def setup
- `git clean -dfx server/; git checkout server/`
- Gemcutter.indexer.generate_index
- end
-
- context "with a filesystem vault" do
- setup do
- @rubygem = Rubygem.new
- @spec = gem_spec
-
- class TestFS
- include Vault::FS
- end
- @vault = TestFS.new
- stub(@vault).rubygem { @rubygem }
- stub(@vault).spec { @spec }
- stub(@vault).body { StringIO.new("lots of data") }
- end
-
- context "loading source index" do
- setup do
- @path = Gemcutter.server_path("source_index")
- @source_index = "source_index"
- end
-
- should "load up the source index from the file system" do
- stub(File).exists?(@path) { true }
-
- zipped = "zipped"
- marshalled = "marshalled"
-
- mock(File).read(@path) { zipped }
- mock(Gem).inflate(zipped) { marshalled }
- mock(Marshal).load(marshalled) { @source_index }
-
- assert_equal @source_index, @vault.source_index
- end
-
- should "create a new source index if it's not there" do
- stub(File).exists?(@path) { false }
- stub(Gem::SourceIndex).new { @source_index }
- assert_equal @source_index, @vault.source_index
- end
- end
-
- should "write the gem" do
- @vault.write_gem
-
- cache_path = Gemcutter.server_path("gems", "#{@spec.original_name}.gem")
- assert File.exists?(cache_path)
- assert_equal 0100644, File.stat(cache_path).mode
-
- quick_path = Gemcutter.server_path("quick", "Marshal.#{Gem.marshal_version}", "#{@spec.original_name}.gemspec.rz")
- assert File.exists?(quick_path)
- assert_equal 0100644, File.stat(quick_path).mode
-
- quick_gem_data = File.open(quick_path, 'rb') { |f| Marshal.load(Gem.inflate(f.read)) }
- Gemcutter.indexer.abbreviate @spec
- Gemcutter.indexer.sanitize @spec
- assert_equal @spec, quick_gem_data
- end
-
- should "update the index" do
- @vault.update_index
-
- source_index = Gemcutter.server_path("source_index")
- assert File.exists?(source_index)
-
- source_index_data = File.open(source_index) { |f| Marshal.load(Gem.inflate(f.read)) }
- assert source_index_data.gems.has_key?(@spec.original_name)
-
- latest_specs = Gemcutter.server_path("latest_specs.4.8")
- assert File.exists?(latest_specs)
-
- latest_specs_data = File.open(latest_specs) { |f| Marshal.load f.read }
- assert_equal 1, latest_specs_data.size
- assert_equal ["test", Gem::Version.new("0.0.0"), "ruby"], latest_specs_data.first
- end
- end
-
- context "with an amazon s3 vault" do
- setup do
- @vault = stub!
- @vault.include Vault::S3
- end
-
- should "respond to store" do
- @vault.respond_to?(:store)
- end
- end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.