Class: Racket::Utils::Application::RegistryBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/racket/utils/application/registry_builder.rb

Overview

Class for easily building a Racket::Registry.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(settings = {}) ⇒ RegistryBuilder

Returns a new instance of RegistryBuilder.



30
31
32
33
# File 'lib/racket/utils/application/registry_builder.rb', line 30

def initialize(settings = {})
  @settings = settings
  @registry = Racket::Registry.singleton_map(service_map)
end

Instance Attribute Details

#registryObject (readonly)

Returns the value of attribute registry.



28
29
30
# File 'lib/racket/utils/application/registry_builder.rb', line 28

def registry
  @registry
end

Class Method Details

.static_server(static_dir, logger) ⇒ Proc|nil

Sets up a static server with the specified directory and logger.

Parameters:

  • static_dir (Pathname|nil)
  • logger (Logger)

Returns:

  • (Proc|nil)


40
41
42
43
44
45
46
47
48
# File 'lib/racket/utils/application/registry_builder.rb', line 40

def self.static_server(static_dir, logger)
  unless static_dir
    logger.inform_dev('Static server disabled.')
    return nil
  end
  logger.inform_dev("Setting up static server to serve files from #{static_dir}.")
  handler = Rack::File.new(static_dir)
  ->(env) { handler.call(env) }
end