module Geminabox::Indexer

Public Class Methods

germane?() click to toggle source
# File lib/geminabox/indexer.rb, line 15
def self.germane?
  gem_version = Gem::Version.new(Gem::VERSION)
  v1_8        = Gem::Version.new('1.8')
  v1_8_25     = Gem::Version.new('1.8.25')

  (gem_version >= v1_8) && (gem_version < v1_8_25)
end
patch_rubygems_update_index_pre_1_8_25(indexer) click to toggle source
# File lib/geminabox/indexer.rb, line 36
def self.patch_rubygems_update_index_pre_1_8_25(indexer)
  if germane?
    specs = updated_gemspecs(indexer)

    unless specs.empty?
      Gem::Specification.dirs = []
      Gem::Specification.add_specs(*specs)
    end
  end
end
updated_gemspecs(indexer) click to toggle source
# File lib/geminabox/indexer.rb, line 23
def self.updated_gemspecs(indexer)
  specs_mtime = File.stat(indexer.dest_specs_index).mtime rescue Time.at(0)
  newest_mtime = Time.at 0

  updated_gems = indexer.gem_file_list.select do |gem|
    gem_mtime = File.stat(gem).mtime
    newest_mtime = gem_mtime if gem_mtime > newest_mtime
    gem_mtime >= specs_mtime
  end

  indexer.map_gems_to_specs updated_gems
end