Sha256: 4dc22c18ec7e9f459c93fb336bf89ca3b78cdbe9fe49d066a81818f7a4628206

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

require "cogger"
require "dry-container"
require "etcher"
require "runcom"
require "spek"

module Rubysmith
  # Provides a global gem container for injection into other objects.
  module Container
    extend Dry::Container::Mixin

    register :configuration do
      self[:defaults].add_loader(Etcher::Loaders::YAML.new(self[:xdg_config].active))
                     .then { |registry| Etcher.call registry }
    end

    register :defaults do
      Etcher::Registry.new(contract: Configuration::Contract, model: Configuration::Model)
                      .add_loader(Etcher::Loaders::YAML.new(self[:defaults_path]))
                      .add_transformer(Configuration::Transformers::CurrentTime)
                      .add_transformer(Configuration::Transformers::GitHubUser)
                      .add_transformer(Configuration::Transformers::GitEmail)
                      .add_transformer(Configuration::Transformers::GitUser)
                      .add_transformer(Configuration::Transformers::TemplateRoot)
                      .add_transformer(Configuration::Transformers::TargetRoot)
    end

    register(:input, memoize: true) { self[:configuration].dup }
    register(:defaults_path) { Pathname(__dir__).join("configuration/defaults.yml") }
    register(:xdg_config) { Runcom::Config.new "rubysmith/configuration.yml" }
    register(:specification) { Spek::Loader.call "#{__dir__}/../../rubysmith.gemspec" }
    register(:kernel) { Kernel }
    register(:logger) { Cogger.new formatter: :emoji }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubysmith-5.0.1 lib/rubysmith/container.rb