Module: Kapellmeister::Base

Defined in:
lib/kapellmeister/base.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.routes_scheme_parse(path) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/kapellmeister/base.rb', line 28

def self.routes_scheme_parse(path)
  template = ERB.new(File.read(path)).result
  YAML.safe_load(template, aliases: true, permitted_classes: [Symbol, Date, Time]).deep_symbolize_keys
rescue Errno::ENOENT
  warn 'No such file or directory', path
  {}
end

Instance Method Details

#configurationObject



2
3
4
# File 'lib/kapellmeister/base.rb', line 2

def configuration
  @configuration ||= self::Configuration.new
end

#configure {|configuration| ... } ⇒ Object

Yields:



10
11
12
# File 'lib/kapellmeister/base.rb', line 10

def configure
  yield(configuration)
end

#loggerObject



14
15
16
# File 'lib/kapellmeister/base.rb', line 14

def logger
  @logger ||= configuration.logger
end

#report(data) ⇒ Object



6
7
8
# File 'lib/kapellmeister/base.rb', line 6

def report(data)
  responder.new(data)
end

#requestsObject



18
19
20
21
22
# File 'lib/kapellmeister/base.rb', line 18

def requests
  @requests ||= generate_routes(self::ROUTES).transform_values! do |value|
    value.except!(:use_wrapper)
  end
end

#responderObject



24
25
26
# File 'lib/kapellmeister/base.rb', line 24

def responder
  @responder ||= defined?(self::Responder) ? self::Responder : Kapellmeister::Responder
end