Sha256: 4af6b8489b17236c487227e6e166134f416c83f905f79db4c5023ee82add09f2
Contents?: true
Size: 1.43 KB
Versions: 1
Compression:
Stored size: 1.43 KB
Contents
require 'dry-initializer' require 'gm/notepad/container' require 'gm/notepad/throughput_text' module Gm module Notepad # Responsible for recording entries and then dumping them accordingly. class App extend Dry::Initializer option :renderer, default: -> { Container.resolve(:renderer) } option :input_processor, default: -> { Container.resolve(:input_processor) } option :report_config, default: -> { Container.resolve(:config).report_config }, reader: :private option :list_tables, default: -> { Container.resolve(:config).list_tables }, reader: :private def initialize(*args) super open! end def process(text:) output = input_processor.convert_to_output(input: text) renderer.render(output: output) end def close! renderer.close! end private def open! renderer.call("Welcome to gm-notepad. type \"?\" for help.", to_interactive: true, to_output: false) return unless report_config lines = ["# Configuration Parameters:"] Config.settings.each do |setting| lines << "# config[#{setting.inspect}] = #{Config.public_send(setting).inspect}" end # When running :list_tables by default I don't want to report # that to the output buffer. to_output = !list_tables renderer.call(lines, to_interactive: true, to_output: to_output) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gm-notepad-0.0.11 | lib/gm/notepad/app.rb |