-
Notifications
You must be signed in to change notification settings - Fork 14
/
repl.rb
35 lines (26 loc) · 663 Bytes
/
repl.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
$LOAD_PATH.unshift File.expand_path(File.join("lib", File.dirname(__FILE__)))
require 'coolline'
require 'coderay'
require 'pp'
Coolline.bind "\C-z" do |c|
c.menu.string = "Coolline object id: #{c.object_id}"
end
cool = Coolline.new do |c|
c.transform_proc = proc do
CodeRay.scan(c.line, :ruby).term
end
c.completion_proc = proc do
word = c.completed_word
Object.constants.map(&:to_s).select { |w| w.start_with? word }
end
end
# At some point, it became frustrating to just print lines without showing any
# result.
loop do
line = cool.readline
break if line == "exit\n"
obj = eval(line)
print "=> "
pp obj
end
cool.close