Mercurial > hg > soundsoftware-site
comparison vendor/gems/coderay-0.9.7/lib/coderay/encoders/debug.rb @ 210:0579821a129a
Update to Redmine trunk rev 4802
author | Chris Cannam |
---|---|
date | Tue, 08 Feb 2011 13:51:46 +0000 |
parents | vendor/plugins/coderay-0.9.2/lib/coderay/encoders/debug.rb@513646585e45 |
children |
comparison
equal
deleted
inserted
replaced
128:07fa8a8b56a8 | 210:0579821a129a |
---|---|
1 module CodeRay | |
2 module Encoders | |
3 | |
4 # = Debug Encoder | |
5 # | |
6 # Fast encoder producing simple debug output. | |
7 # | |
8 # It is readable and diff-able and is used for testing. | |
9 # | |
10 # You cannot fully restore the tokens information from the | |
11 # output, because consecutive :space tokens are merged. | |
12 # Use Tokens#dump for caching purposes. | |
13 class Debug < Encoder | |
14 | |
15 include Streamable | |
16 register_for :debug | |
17 | |
18 FILE_EXTENSION = 'raydebug' | |
19 | |
20 protected | |
21 def text_token text, kind | |
22 if kind == :space | |
23 text | |
24 else | |
25 text = text.gsub(/[)\\]/, '\\\\\0') # escape ) and \ | |
26 "#{kind}(#{text})" | |
27 end | |
28 end | |
29 | |
30 def open_token kind | |
31 "#{kind}<" | |
32 end | |
33 | |
34 def close_token kind | |
35 ">" | |
36 end | |
37 | |
38 def begin_line kind | |
39 "#{kind}[" | |
40 end | |
41 | |
42 def end_line kind | |
43 "]" | |
44 end | |
45 | |
46 end | |
47 | |
48 end | |
49 end |