Sha256: 886e42fb150129c2ca9aa9b6d45777bc6400f4116261d69047afbe91fe54b04b

Contents?: true

Size: 951 Bytes

Versions: 4

Compression:

Stored size: 951 Bytes

Contents

# frozen_string_literal: true

require "cogger"
require "containable"
require "etcher"
require "http"
require "runcom"
require "spek"

module Pennyworth
  # Provides a global gem container for injection into other objects.
  module Container
    extend Containable

    register :registry do
      Etcher::Registry.new(contract: Configuration::Contract, model: Configuration::Model)
                      .add_loader(:yaml, self[:defaults_path])
                      .add_loader(:yaml, self[:xdg_config].active)
    end

    register(:settings) { Etcher.call(self[:registry]).dup }
    register(:specification) { Spek::Loader.call "#{__dir__}/../../pennyworth.gemspec" }
    register(:defaults_path) { Pathname(__dir__).join("configuration/defaults.yml") }
    register(:xdg_config) { Runcom::Config.new "pennyworth/configuration.yml" }
    register :http, HTTP
    register(:logger) { Cogger.new id: :pennyworth }
    register :io, STDOUT
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pennyworth-17.3.0 lib/pennyworth/container.rb
pennyworth-17.2.0 lib/pennyworth/container.rb
pennyworth-17.1.0 lib/pennyworth/container.rb
pennyworth-17.0.0 lib/pennyworth/container.rb