Sha256: eb6be06cc39311cb608345c4a05a52d7e9f70a15e1f19cafadfe4b0766618a92
Contents?: true
Size: 791 Bytes
Versions: 2
Compression:
Stored size: 791 Bytes
Contents
#!/usr/bin/env ruby # Repl Example # # A simple interactive example for running a repl in flammarion require 'flammarion' class FlammarionRepl def initialize @f = Flammarion::Engraving.new(exit_on_disconnect:true) @f.subpane("output") @f.input("> ", autoclear:true, history:true) {|msg| repl(msg['text']) } end def repl(str) @f.subpane("output").puts "> #{str}" result = begin eval(str).to_s.green rescue Exception => e "#{e}".red end @f.subpane("output").puts result end def puts(str) @f.subpane("output").puts "#{str}" end end module Kernel def puts(str) $repl.puts(str) end end if __FILE__ == $0 then $repl = FlammarionRepl.new $repl.wait_until_closed end
Version data entries
2 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
flammarion-utils-0.3.0 | bin/flammarion-repl |
flammarion-utils-0.3.0 | bin/repl |