Module: Etcher
- Defined in:
- lib/etcher.rb,
lib/etcher/types.rb,
lib/etcher/finder.rb,
lib/etcher/builder.rb,
lib/etcher/contract.rb,
lib/etcher/registry.rb,
lib/etcher/resolver.rb,
lib/etcher/loaders/hash.rb,
lib/etcher/loaders/json.rb,
lib/etcher/loaders/yaml.rb,
lib/etcher/transformers/root.rb,
lib/etcher/transformers/time.rb,
lib/etcher/loaders/environment.rb,
lib/etcher/transformers/format.rb,
lib/etcher/transformers/basename.rb
Overview
Finds internal constant if moniker matches, otherwise answers a failure.
Defined Under Namespace
Modules: Loaders, Transformers, Types Classes: Builder, Registry, Resolver
Constant Summary collapse
- LOGGER =
Cogger.new id: :etcher
- Finder =
lambda do |namespace, moniker| Etcher.const_get(namespace) .constants .find { |constant| constant.downcase == moniker } .then do |constant| return Dry::Monads::Success Etcher.const_get("#{namespace}::#{constant}") if constant Dry::Monads::Failure "Unable to select #{moniker.inspect} within #{namespace.downcase}." end rescue NameError Dry::Monads::Failure "Invalid namespace: #{namespace.inspect}." end
- Contract =
A simple passthrough contract.
lambda do |result| def result.to_monad = Dry::Monads::Success self unless result.respond_to? :to_monad result end
Class Method Summary collapse
- .call(registry = Registry.new) ⇒ Object
- .loader(registry = Zeitwerk::Registry) ⇒ Object
- .new ⇒ Object
Class Method Details
.call(registry = Registry.new) ⇒ Object
23 |
# File 'lib/etcher.rb', line 23 def self.call(registry = Registry.new, **) = Resolver.new(registry).call(**) |
.loader(registry = Zeitwerk::Registry) ⇒ Object
17 18 19 |
# File 'lib/etcher.rb', line 17 def self.loader registry = Zeitwerk::Registry @loader ||= registry.loaders.each.find { |loader| loader.tag == File.basename(__FILE__, ".rb") } end |
.new ⇒ Object
21 |
# File 'lib/etcher.rb', line 21 def self.new(...) = Builder.new(...) |