Sha256: e92d44b347daaac10b865e8e465eb8102fb9ef3f1d34504cdd0755b29c3b9c76

Contents?: true

Size: 1.83 KB

Versions: 3

Compression:

Stored size: 1.83 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(Etcher::Loaders::YAML.new(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(Etcher::Loaders::YAML.new(self[:defaults_path]))
              .add_transformer(Rubysmith::Configuration::Transformers::CurrentTime)
              .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)
    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

3 entries across 3 versions & 1 rubygems

Version Path
gemsmith-21.6.0 lib/gemsmith/container.rb
gemsmith-21.5.1 lib/gemsmith/container.rb
gemsmith-21.5.0 lib/gemsmith/container.rb