Class: Geminabox::Server
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Geminabox::Server
- Defined in:
- lib/geminabox/server.rb
Class Method Summary collapse
- .allow_delete? ⇒ Boolean
- .allow_upload? ⇒ Boolean
- .dependency_cache ⇒ Object
- .disallow_replace? ⇒ Boolean
-
.file_class ⇒ Object
This method provides a test hook, as stubbing File is painful…
- .file_class=(klass) ⇒ Object
- .fixup_bundler_rubygems! ⇒ Object
- .indexer ⇒ Object
- .reindex(force_rebuild = false) ⇒ Object
- .with_rlock(&block) ⇒ Object
Class Method Details
.allow_delete? ⇒ Boolean
24 25 26 |
# File 'lib/geminabox/server.rb', line 24 def allow_delete? Geminabox.allow_delete end |
.allow_upload? ⇒ Boolean
28 29 30 |
# File 'lib/geminabox/server.rb', line 28 def allow_upload? Geminabox.allow_upload end |
.dependency_cache ⇒ Object
66 67 68 |
# File 'lib/geminabox/server.rb', line 66 def dependency_cache @dependency_cache ||= Geminabox::DiskCache.new(File.join(Geminabox.data, "_cache")) end |
.disallow_replace? ⇒ Boolean
20 21 22 |
# File 'lib/geminabox/server.rb', line 20 def disallow_replace? ! Geminabox.allow_replace end |
.file_class ⇒ Object
This method provides a test hook, as stubbing File is painful…
77 78 79 |
# File 'lib/geminabox/server.rb', line 77 def file_class @file_class ||= File end |
.file_class=(klass) ⇒ Object
81 82 83 |
# File 'lib/geminabox/server.rb', line 81 def file_class=(klass) @file_class = klass end |
.fixup_bundler_rubygems! ⇒ Object
32 33 34 35 36 |
# File 'lib/geminabox/server.rb', line 32 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 |
.indexer ⇒ Object
62 63 64 |
# File 'lib/geminabox/server.rb', line 62 def indexer Gem::Indexer.new(Geminabox.data, :build_legacy => Geminabox.build_legacy) end |
.reindex(force_rebuild = false) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/geminabox/server.rb', line 38 def reindex(force_rebuild = false) fixup_bundler_rubygems! force_rebuild = true unless Geminabox.incremental_updates if force_rebuild indexer.generate_index dependency_cache.flush else begin require 'geminabox/indexer' updated_gemspecs = Geminabox::Indexer.updated_gemspecs(indexer) return if updated_gemspecs.empty? indexer.update_index updated_gemspecs.each { |gem| dependency_cache.flush_key(gem.name) } rescue Errno::ENOENT with_rlock { reindex(:force_rebuild) } rescue => e puts "#{e.class}:#{e.}" puts e.backtrace.join("\n") with_rlock { reindex(:force_rebuild) } end end rescue Gem::SystemExitException end |