Sha256: e1f056c5169dbbe6d4eb4883603b6e341f062ff831464898fe720252e0f30e71

Contents?: true

Size: 1.65 KB

Versions: 1

Compression:

Stored size: 1.65 KB

Contents

require 'dry-container'

module Gm
  module Notepad
    # A container for dependency injection
    class Container
      extend Dry::Container::Mixin

      register "input_processor" do
        require 'gm/notepad/input_processor'
        InputProcessor.new
      end

      register "config" do
        require 'gm/notepad/config'
        Config
      end

      register "table_registry" do
        require 'gm/notepad/table_registry'
        TableRegistry.build_and_load
      end

      register "renderer" do
        require 'gm/notepad/line_renderer'
        LineRenderer.new
      end

      register "input_handler_registry" do
        # Order matters. The first registered will be the first to
        # answer "Can you handle the input?"
        require "gm/notepad/input_handler_registry"
        require "gm/notepad/input_handlers/help_handler"
        require "gm/notepad/input_handlers/comment_handler"
        require "gm/notepad/input_handlers/query_table_handler"
        require "gm/notepad/input_handlers/query_table_names_handler"
        require "gm/notepad/input_handlers/write_to_table_handler"
        require "gm/notepad/input_handlers/write_line_handler"
        InputHandlerRegistry.new do |registry|
          registry.register(handler: InputHandlers::HelpHandler)
          registry.register(handler: InputHandlers::CommentHandler)
          registry.register(handler: InputHandlers::QueryTableHandler)
          registry.register(handler: InputHandlers::QueryTableNamesHandler)
          registry.register(handler: InputHandlers::WriteToTableHandler)
          registry.register(handler: InputHandlers::WriteLineHandler)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gm-notepad-0.0.11 lib/gm/notepad/container.rb