Module: Dcc::Server
- Defined in:
- lib/dcc/server.rb,
lib/dcc/server/app.rb,
lib/dcc/server/storage.rb,
lib/dcc/server/storage/entry.rb,
lib/dcc/server/storage/memory.rb
Defined Under Namespace
Class Method Summary collapse
-
.available? ⇒ Boolean
Attempt to load sinatra to detect availability.
-
.ensure_available! ⇒ Object
Raise a friendly error if Sinatra is missing.
Class Method Details
.available? ⇒ Boolean
Attempt to load sinatra to detect availability.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/dcc/server.rb', line 12 def self.available? return @available unless @available.nil? begin require "sinatra/base" @available = true rescue ::LoadError @available = false end @available end |
.ensure_available! ⇒ Object
Raise a friendly error if Sinatra is missing.
25 26 27 28 29 30 31 |
# File 'lib/dcc/server.rb', line 25 def self.ensure_available! return if available? raise ::Dcc::MissingDependencyError.new(gem_name: "sinatra", feature: "Dcc::Server REST API"), "sinatra is required for the REST API" end |