Class: Geminabox::Server

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/geminabox/server.rb

Class Method Summary collapse

Class Method Details

.allow_delete?Boolean

Returns:

  • (Boolean)

35
36
37
# File 'lib/geminabox/server.rb', line 35

def allow_delete?
  allow_delete
end

.delegate_to_geminabox(*delegate_methods) ⇒ Object


6
7
8
# File 'lib/geminabox/server.rb', line 6

def self.delegate_to_geminabox(*delegate_methods)
  delegate_methods.each{|m| set m, Geminabox.send(m)}
end

.dependency_cacheObject


70
71
72
# File 'lib/geminabox/server.rb', line 70

def dependency_cache
  @dependency_cache ||= Geminabox::DiskCache.new(File.join(data, "_cache"))
end

.disallow_replace?Boolean

Returns:

  • (Boolean)

31
32
33
# File 'lib/geminabox/server.rb', line 31

def disallow_replace?
  ! allow_replace
end

.fixup_bundler_rubygems!Object


39
40
41
42
43
# File 'lib/geminabox/server.rb', line 39

def fixup_bundler_rubygems!
  return if @post_reset_hook_applied
  Gem.post_reset{ Gem::Specification.all = nil } if defined? Bundler and Gem.respond_to? :post_reset
  @post_reset_hook_applied = true
end

.indexerObject


66
67
68
# File 'lib/geminabox/server.rb', line 66

def indexer
  Gem::Indexer.new(data, :build_legacy => build_legacy)
end

.reindex(force_rebuild = false) ⇒ Object


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/geminabox/server.rb', line 45

def reindex(force_rebuild = false)
  fixup_bundler_rubygems!
  force_rebuild = true unless incremental_updates
  if force_rebuild
    indexer.generate_index
    dependency_cache.flush
  else
    begin
      require 'geminabox/indexer'
      updated_gemspecs = Geminabox::Indexer.updated_gemspecs(indexer)
      Geminabox::Indexer.patch_rubygems_update_index_pre_1_8_25(indexer)
      indexer.update_index
      updated_gemspecs.each { |gem| dependency_cache.flush_key(gem.name) }
    rescue => e
      puts "#{e.class}:#{e.message}"
      puts e.backtrace.join("\n")
      reindex(:force_rebuild)
    end
  end
end