Sha256: 8b5d31fdb020fd023338078aec57c8a84240ce5f4c1cbfdc141fe80ed2b7c13a

Contents?: true

Size: 1.7 KB

Versions: 9

Compression:

Stored size: 1.7 KB

Contents

# frozen_string_literal: true

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

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

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

    register :defaults, memoize: true 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.new)
                      .add_transformer(Configuration::Transformers::GitEmail.new)
                      .add_transformer(Configuration::Transformers::GitUser.new)
                      .add_transformer(Configuration::Transformers::TemplateRoot.new)
                      .add_transformer(Configuration::Transformers::TargetRoot)
    end

    register :specification, memoize: true do
      Spek::Loader.call "#{__dir__}/../../rubysmith.gemspec"
    end

    register(:input, memoize: true) { self[:configuration].dup }
    register(:defaults_path, memoize: true) { Pathname(__dir__).join("configuration/defaults.yml") }
    register(:xdg_config, memoize: true) { Runcom::Config.new "rubysmith/configuration.yml" }
    register(:git, memoize: true) { Gitt::Repository.new }
    register(:logger, memoize: true) { Cogger.new id: :rubysmith }
    register :kernel, Kernel
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rubysmith-6.4.0 lib/rubysmith/container.rb
rubysmith-6.3.0 lib/rubysmith/container.rb
rubysmith-6.2.1 lib/rubysmith/container.rb
rubysmith-6.2.0 lib/rubysmith/container.rb
rubysmith-6.1.0 lib/rubysmith/container.rb
rubysmith-6.0.0 lib/rubysmith/container.rb
rubysmith-5.9.0 lib/rubysmith/container.rb
rubysmith-5.8.1 lib/rubysmith/container.rb
rubysmith-5.8.0 lib/rubysmith/container.rb