Sha256: 4197d9a646193fe1b7ff0941078792476088eed67d2fccb8eeda3cfbf6de2041

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

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

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

    # :nocov:
    register :configuration do
      self[:defaults].add_loader(Etcher::Loaders::Environment.new(%w[HOME]))
                     .add_loader(Etcher::Loaders::YAML.new(self[:xdg_config].active))
                     .add_transformer(Configuration::Transformers::SessionPath.new)
                     .add_transformer(Configuration::Transformers::UserDir.new)
                     .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]))
    end

    register(:defaults_path) { Pathname(__dir__).join("configuration/defaults.yml") }
    register(:xdg_config) { Runcom::Config.new "sublime_text_kit/configuration.yml" }
    register(:specification) { Spek::Loader.call "#{__dir__}/../../sublime_text_kit.gemspec" }
    register(:kernel) { Kernel }
    register(:logger) { Cogger.new formatter: :emoji }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sublime_text_kit-15.0.0 lib/sublime_text_kit/container.rb