module EasyRepl::Repl
Public Instance Methods
commands()
click to toggle source
# File lib/easy_repl/repl.rb, line 61 def commands @commands ||= [EasyRepl::Commands::Exit, EasyRepl::Commands::Reload] end
gets()
click to toggle source
# File lib/easy_repl/repl.rb, line 50 def gets input = prompt.gets command = commands.find {|c| c.matches(input)} if command return command.run(input) else return input end end
start() { |gets| ... }
click to toggle source
# File lib/easy_repl/repl.rb, line 18 def start IRB::HistorySavingAbility.extend(IRB::HistorySavingAbility) unless IRB::HistorySavingAbility === IRB::HistorySavingAbility loop do #outer loop setup if respond_to? :setup begin exit_inner_loop_value = catch(:exit_inner_loop) do loop do #inner loop begin catch(:skip_process_input) do before_input if respond_to? :before_input if block_given? yield self.gets elsif respond_to? :process_input process_input(self.gets) else puts self.gets end end ensure after_input if respond_to? :after_input end end end return if exit_inner_loop_value == :exit ensure teardown if respond_to? :teardown end end ensure IRB::HistorySavingAbility.save_history end
Private Instance Methods
prompt()
click to toggle source
# File lib/easy_repl/repl.rb, line 66 def prompt @io ||= IRB::ReadlineInputMethod.new.tap do |new_io| new_io.prompt = "> " end end