Created
June 6, 2016 23:27
-
-
Save z2s8/92f6cd504f4206addb0b16620c1597dd to your computer and use it in GitHub Desktop.
dumb repl in 20 lines of ruby.. todo: wrap exec maybe to crosslang?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
def save_line(line) | |
open('repldata', 'a') do |repldata| | |
repldata.puts "puts %s(> #{line.rstrip})" | |
repldata.puts "print('= ')" | |
repldata.puts "puts(#{line})" | |
end | |
end | |
def exec_file | |
system "clear" or system "cls" | |
`ruby repldata` | |
end | |
loop do | |
print '> ' | |
save_line gets | |
puts exec_file | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment