Module: Geminabox::Indexer

Defined in:
lib/geminabox/indexer.rb

Class Method Summary collapse

Class Method Details

.germane?Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
# 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) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# 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) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/geminabox/indexer.rb', line 23

def self.updated_gemspecs(indexer)
  specs_mtime = File.stat(indexer.dest_specs_index).mtime
  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