Sha256: b997e19868a91ff5da185d7e63c8b981a8808a4a9fe866dea36fb08285959daa

Contents?: true

Size: 1.75 KB

Versions: 2

Compression:

Stored size: 1.75 KB

Contents

# frozen_string_literal: true

require "cogger"
require "containable"
require "etcher"
require "open3"
require "runcom"
require "spek"

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

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

    register :defaults do
      registry = Etcher::Registry.new contract: Rubysmith::Configuration::Contract,
                                      model: Rubysmith::Configuration::Model

      registry.add_loader(:yaml, self[:defaults_path])
              .add_transformer(Rubysmith::Configuration::Transformers::GitHubUser.new)
              .add_transformer(Rubysmith::Configuration::Transformers::GitEmail.new)
              .add_transformer(Rubysmith::Configuration::Transformers::GitUser.new)
              .add_transformer(Rubysmith::Configuration::Transformers::TemplateRoot.new)
              .add_transformer(
                Rubysmith::Configuration::Transformers::TemplateRoot.new(
                  default: Pathname(__dir__).join("templates")
                )
              )
              .add_transformer(Rubysmith::Configuration::Transformers::TargetRoot)
              .add_transformer(:time)
    end

    register(:specification) { Spek::Loader.call "#{__dir__}/../../gemsmith.gemspec" }
    register(:input) { self[:configuration].dup }
    register(:defaults_path) { Rubysmith::Container[:defaults_path] }
    register(:xdg_config) { Runcom::Config.new "gemsmith/configuration.yml" }
    register :environment, ENV
    register(:logger) { Cogger.new id: :gemsmith }
    register :executor, Open3
    register :kernel, Kernel
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gemsmith-21.10.0 lib/gemsmith/container.rb
gemsmith-21.9.0 lib/gemsmith/container.rb