Sha256: e559e5fedff040e65073b121a34177b19b3435c12bc48da5830fc74edde2207c
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 KB
Contents
require 'vedeu/instrumentation' require 'vedeu/support/input' require 'vedeu/support/terminal' module Vedeu ModeSwitch = Class.new(StandardError) class Application def self.start(options = {}) new(options).start end def initialize(options = {}) @options = options end def start Terminal.open(mode) do Terminal.set_cursor_mode Vedeu.events.trigger(:_initialize_) runner { main_sequence } end end private attr_reader :options def runner if interactive? interactive { yield } else run_once { yield } end end def main_sequence Input.capture end def interactive? options.fetch(:interactive) end def interactive loop { yield } rescue ModeSwitch if Terminal.raw_mode? Application.start({ mode: :cooked }) else Application.start({ mode: :raw }) end end def run_once yield end def mode options.fetch(:mode) end def debug Vedeu::Instrumentation::Trace.call if options.fetch(:debug) end def options defaults.merge!(@options) end def defaults { debug: false, interactive: true, mode: :raw } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.1.9 | lib/vedeu/application.rb |
vedeu-0.1.8 | lib/vedeu/application.rb |