Sha256: 2342240db19742e89ad7dc072a89ca32949f80ca77b9c0bdab7e197b8fe890b2

Contents?: true

Size: 965 Bytes

Versions: 2

Compression:

Stored size: 965 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.timeout 3 }
    register(:logger) { Cogger.new id: :pennyworth }
    register :io, STDOUT
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pennyworth-17.4.1 lib/pennyworth/container.rb
pennyworth-17.4.0 lib/pennyworth/container.rb