Sha256: 1fc784f59055b2c601a37f8f502bec5a4b207869f1f8eaf6eff76ac708b92401
Contents?: true
Size: 1.25 KB
Versions: 3
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true require "dry-container" require "logger" require "http" require "pastel" require "spek" module Pennyworth # Provides a global gem container for injection into other objects. module Container extend Dry::Container::Mixin register(:configuration) { Configuration::Loader.call } register(:specification) { Spek::Loader.call "#{__dir__}/../../pennyworth.gemspec" } register(:environment) { ENV } register(:kernel) { Kernel } register(:http) { HTTP } register(:colorizer) { Pastel.new enabled: $stdout.tty? } register :log_colors do { "DEBUG" => self[:colorizer].white.detach, "INFO" => self[:colorizer].green.detach, "WARN" => self[:colorizer].yellow.detach, "ERROR" => self[:colorizer].red.detach, "FATAL" => self[:colorizer].white.bold.on_red.detach, "ANY" => self[:colorizer].white.bold.detach } end register :logger do Logger.new $stdout, level: Logger.const_get(ENV.fetch("LOG_LEVEL", "INFO")), formatter: ( lambda do |severity, _at, _name, message| self[:log_colors][severity].call "#{message}\n" end ) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pennyworth-12.3.1 | lib/pennyworth/container.rb |
pennyworth-12.3.0 | lib/pennyworth/container.rb |
pennyworth-12.2.0 | lib/pennyworth/container.rb |