-
Notifications
You must be signed in to change notification settings - Fork 17
/
wrapper.rb
64 lines (53 loc) · 1.45 KB
/
wrapper.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
module PryCoolline
Wrapper = Struct.new(:cool) do
def readline(prompt)
cool.readline prompt
end
def completion_proc=(proc)
cool.completion_proc = proc do
proc.call cool.completed_word
end
end
def bond_adapter
cool = self.cool
Module.new.extend(Module.new{
define_method(:setup){ |*| }
define_method(:line_buffer){ cool.line }
})
end
end
module_function
# @return [Coolline]
def make_coolline
Coolline.new do |cool|
cool.completion_word_boundaries =
[" ", "\t", ",", ";", '"', "'", "`", "<", ">",
"=", ";", "|", "{", "}", "(", ")", "-"]
cool.word_boundaries = cool.completion_word_boundaries +
[".", ":"]
pry_history_file =
if Gem::Version.new(Pry::VERSION) >= Gem::Version.new("0.13")
Pry.config.history_file
else
Pry.config.history.file
end
# bring saved history into coolline
cool.history_file = File.expand_path(pry_history_file)
cool.transform_proc = proc do
if Pry.color
code = CodeRay.scan(cool.line, :ruby).term
if Pry.config.coolline_paren_matching
PryCoolline.apply_paren_matching(code, cool.pos)
end
code
else
cool.line
end
end
end
end
# @return [Wrapper] An object usable as an input object for Pry.
def make_input
Wrapper.new make_coolline
end
end