Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

88 lines (70 sloc) 2.039 kb
class Indexer
extend StatsD::Instrument
def perform
log "Updating the index"
update_index
log "Finished updating the index"
end
statsd_count_success :perform, 'Indexer.perform.success'
statsd_measure :perform, 'Indexer.perform'
def write_gem(body, spec)
RubygemFs.instance.store("gems/#{spec.original_name}.gem",
body.string)
self.class.indexer.abbreviate spec
self.class.indexer.sanitize spec
RubygemFs.instance.store(
"quick/Marshal.4.8/#{spec.original_name}.gemspec.rz",
Gem.deflate(Marshal.dump(spec)))
end
private
def stringify(value)
final = StringIO.new
gzip = Zlib::GzipWriter.new(final)
gzip.write(Marshal.dump(value))
gzip.close
final.string
end
def upload(key, value)
RubygemFs.instance.store(key, stringify(value))
end
def update_index
upload("specs.4.8.gz", specs_index)
log "Uploaded all specs index"
upload("latest_specs.4.8.gz", latest_index)
log "Uploaded latest specs index"
upload("prerelease_specs.4.8.gz", prerelease_index)
log "Uploaded prerelease specs index"
end
def minimize_specs(data)
names = Hash.new { |h,k| h[k] = k }
versions = Hash.new { |h,k| h[k] = Gem::Version.new(k) }
platforms = Hash.new { |h,k| h[k] = k }
data.each do |row|
row[0] = names[row[0]]
row[1] = versions[row[1].strip]
row[2] = platforms[row[2]]
end
data
end
def specs_index
minimize_specs Version.rows_for_index
end
def latest_index
minimize_specs Version.rows_for_latest_index
end
def prerelease_index
minimize_specs Version.rows_for_prerelease_index
end
def log(message)
Rails.logger.info "[GEMCUTTER:#{Time.now}] #{message}"
end
def self.indexer
# TODO: remove this after we upgrade rubygems client
@indexer ||=
begin
indexer = Gem::Indexer.new(Rails.root.join("server"), build_legacy: false)
def indexer.say(message) end
indexer
end
end
end
Jump to Line
Something went wrong with that request. Please try again.