Sha256: 3664b1dd0353b7aeac17f5b8dbac976b0f0407bd45d02a612336d2a5098918d2

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

require 'gm/notepad/configuration'
module Gm
  module Notepad
    # Responsible for recording entries and then dumping them accordingly.
    class Pad
      Notepad::Configuration.init!(target: self, from_config: [:table_registry, :renderer, :input_processor]) do
        open!
      end

      def process(input:)
        input_processor.process(input: input) do |*args|
          renderer.call(*args)
        end
      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 config.report_config
        lines = ["# Configuration Parameters:"]
        config.each_pair do |key, value|
          lines << "#   config[#{key.inspect}] = #{value.inspect}"
        end
        # When running :list_tables by default I don't want to report
        # that to the output buffer.
        to_output = !config.list_tables
        renderer.call(lines, to_interactive: true, to_output: to_output)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gm-notepad-0.0.10 lib/gm/notepad/pad.rb
gm-notepad-0.0.9 lib/gm/notepad/pad.rb
gm-notepad-0.0.8 lib/gm/notepad/pad.rb