Module: PryCoolline
- Defined in:
- lib/pry-coolline/version.rb,
lib/pry-coolline/wrapper.rb,
lib/pry-coolline/paren_match.rb
Defined Under Namespace
Modules: ParenMatch Classes: Wrapper
Constant Summary collapse
- VERSION =
"0.2.4"
Class Method Summary collapse
-
.apply_paren_matching(code, pos) ⇒ Object
Adds paren matching code for the parens that are matched at a given position.
- .make_coolline ⇒ Coolline
-
.make_input ⇒ Wrapper
An object usable as an input object for Pry.
Class Method Details
.apply_paren_matching(code, pos) ⇒ Object
Adds paren matching code for the parens that are matched at a given position. The color codes are determined using Pry.config.
267 268 269 270 271 272 273 274 275 276 277 |
# File 'lib/pry-coolline/paren_match.rb', line 267 def apply_paren_matching(code, pos) pair = ParenMatch.pair_at(code, pos) color = pair.correctly_matched? ? Pry.config.coolline_matched_paren : Pry.config.coolline_mismatched_paren pair.insertion_positions.each do |before, after| code.insert after, "\e[0m" code.insert before, color end end |
.make_coolline ⇒ Coolline
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/pry-coolline/wrapper.rb', line 25 def make_coolline Coolline.new do |cool| cool.word_boundaries = [" ", "\t", ",", ";", '"', "'", "`", "<", ">", "=", ";", "|", "{", "}", "(", ")", "-"] # bring saved history into coolline cool.history_file = File.(Pry.config.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 |