Sha256: 8137a46898cd412a44f9674d888a4bff0a9d05c84dbeb0727a79a16d50c5ec3a

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

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)
                      .add_transformer(:format, :htmx_examples_uri)
                      .add_transformer(:format, :htmx_extensions_uri)
                      .add_transformer(:format, :htmx_references_uri)
    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

4 entries across 4 versions & 1 rubygems

Version Path
pennyworth-17.8.0 lib/pennyworth/container.rb
pennyworth-17.7.0 lib/pennyworth/container.rb
pennyworth-17.6.0 lib/pennyworth/container.rb
pennyworth-17.5.0 lib/pennyworth/container.rb