lib/terminalwire/thor.rb in terminalwire-0.1.1 vs lib/terminalwire/thor.rb in terminalwire-0.1.2

- old
+ new

@@ -1,18 +1,22 @@ +require 'thor' + module Terminalwire module Thor class Shell < ::Thor::Shell::Basic extend Forwardable - # Encapsulates all of the IO devices for a Terminalwire connection. - attr_reader :session + # Encapsulates all of the IO resources for a Terminalwire adapter. + attr_reader :context, :session - def_delegators :@session, :stdin, :stdout, :stderr + def_delegators :context, + :stdin, :stdout, :stderr - def initialize(session) - @session = session - super() + def initialize(context, *, **, &) + @context = context + @session = Terminalwire::Rails::Session.new(context:) + super(*,**,&) end end def self.included(base) base.extend ClassMethods @@ -22,22 +26,26 @@ extend Forwardable protected no_commands do - def_delegators :shell, :session - def_delegators :session, :stdout, :stdin, :stderr, :browser - def_delegators :stdout, :puts, :print - def_delegators :stdin, :gets + def_delegators :shell, + :context, :session + def_delegators :context, + :stdout, :stdin, :stderr, :browser + def_delegators :stdout, + :puts, :print + def_delegators :stdin, + :gets end end end module ClassMethods def start(given_args = ARGV, config = {}) - session = config.delete(:session) - config[:shell] = Shell.new(session) if session + context = config.delete(:context) + config[:shell] = Shell.new(context) if context super(given_args, config) end end end -end \ No newline at end of file +end