Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Restoring indexer, adding process rake task
  • Loading branch information
qrush committed May 16, 2009
1 parent ba0b5f0 commit b78be7c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 20 deletions.
13 changes: 13 additions & 0 deletions Rakefile
Expand Up @@ -98,6 +98,19 @@ namespace :import do
end
end
end

desc 'Bring the gems through the gemcutter process'
task :process do
require 'rubygems/installer'
require 'app/helper'

gems = Dir[File.join(ARGV[1], "*.gem")]
puts "Processing #{gems.size} gems..."
gems.each do |gem|
puts gem
Gemcutter::Helper.save_gem(File.open(gem))
end
end
end

begin
Expand Down
1 change: 1 addition & 0 deletions app/app.rb
Expand Up @@ -35,6 +35,7 @@ class App < Sinatra::Default

post '/gems' do
spec, exists = Gemcutter::Helper.save_gem(request.body)
Gemcutter::Helper.indexer.update_index

content_type "text/plain"

Expand Down
13 changes: 9 additions & 4 deletions app/helper.rb
Expand Up @@ -20,8 +20,14 @@ def save_gem(data)
f.write data.read
end

installer = Gem::Installer.new(temp.path, :unpack => true)
spec = installer.spec
begin
spec = Gem::Format.from_file_by_path(temp.path).spec
ruby_spec = spec.to_ruby
rescue Exception => e
puts e
return
end

name = "#{spec.name}-#{spec.version}.gem"

cache_path = Gemcutter::Helper.server_path('cache', name)
Expand All @@ -31,10 +37,9 @@ def save_gem(data)

FileUtils.cp temp.path, cache_path
File.open(spec_path, "w") do |f|
f.write spec.to_ruby
f.write ruby_spec
end

Gemcutter::Helper.indexer.update_index
[spec, exists]
end
end
Expand Down
29 changes: 13 additions & 16 deletions lib/rubygems/indexer.rb
Expand Up @@ -124,9 +124,9 @@ def abbreviate(spec)
def build_indicies(index)
# Marshal gemspecs are used by both modern and legacy RubyGems
build_marshal_gemspecs index
#build_legacy_indicies index if @build_legacy
build_legacy_indicies index if @build_legacy
build_modern_indicies index if @build_modern
#build_rss index
build_rss index

compress_indicies
end
Expand Down Expand Up @@ -263,7 +263,6 @@ def build_modern_index(index, file, name)
platform = Gem::Platform::RUBY if platform.nil? or platform.empty?
[spec.name, spec.version, platform]
end
p specs

specs = compact_specs(specs)
Marshal.dump(specs, io)
Expand Down Expand Up @@ -414,24 +413,22 @@ def collect_specs(gems = gem_file_list)

Gem.time 'loaded' do
gems.each do |gemfile|
# this check can be done at push time
#if File.size(gemfile.to_s) == 0 then
#alert_warning "Skipping zero-length gem: #{gemfile}"
#next
#end
if File.size(gemfile.to_s) == 0 then
alert_warning "Skipping zero-length gem: #{gemfile}"
next
end

begin
spec = Gem::Format.from_file_by_path(gemfile).spec
spec.loaded_from = gemfile

# same with this one
#unless gemfile =~ /\/#{Regexp.escape spec.original_name}.*\.gem\z/i then
#expected_name = spec.full_name
#expected_name << " (#{spec.original_name})" if
#spec.original_name != spec.full_name
#alert_warning "Skipping misnamed gem: #{gemfile} should be named #{expected_name}"
#next
#end
unless gemfile =~ /\/#{Regexp.escape spec.original_name}.*\.gem\z/i then
expected_name = spec.full_name
expected_name << " (#{spec.original_name})" if
spec.original_name != spec.full_name
alert_warning "Skipping misnamed gem: #{gemfile} should be named #{expected_name}"
next
end

abbreviate spec
sanitize spec
Expand Down

0 comments on commit b78be7c

Please sign in to comment.