coderay-beta 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. data/FOLDERS +53 -0
  2. data/LICENSE +504 -0
  3. data/bin/coderay +82 -0
  4. data/bin/coderay_stylesheet +4 -0
  5. data/lib/README +129 -0
  6. data/lib/coderay.rb +320 -0
  7. data/lib/coderay/duo.rb +85 -0
  8. data/lib/coderay/encoder.rb +213 -0
  9. data/lib/coderay/encoders/_map.rb +11 -0
  10. data/lib/coderay/encoders/comment_filter.rb +43 -0
  11. data/lib/coderay/encoders/count.rb +21 -0
  12. data/lib/coderay/encoders/debug.rb +49 -0
  13. data/lib/coderay/encoders/div.rb +19 -0
  14. data/lib/coderay/encoders/filter.rb +75 -0
  15. data/lib/coderay/encoders/html.rb +305 -0
  16. data/lib/coderay/encoders/html/css.rb +70 -0
  17. data/lib/coderay/encoders/html/numerization.rb +133 -0
  18. data/lib/coderay/encoders/html/output.rb +206 -0
  19. data/lib/coderay/encoders/json.rb +69 -0
  20. data/lib/coderay/encoders/lines_of_code.rb +90 -0
  21. data/lib/coderay/encoders/null.rb +26 -0
  22. data/lib/coderay/encoders/page.rb +20 -0
  23. data/lib/coderay/encoders/span.rb +19 -0
  24. data/lib/coderay/encoders/statistic.rb +77 -0
  25. data/lib/coderay/encoders/term.rb +137 -0
  26. data/lib/coderay/encoders/text.rb +32 -0
  27. data/lib/coderay/encoders/token_class_filter.rb +84 -0
  28. data/lib/coderay/encoders/xml.rb +71 -0
  29. data/lib/coderay/encoders/yaml.rb +22 -0
  30. data/lib/coderay/for_redcloth.rb +85 -0
  31. data/lib/coderay/helpers/file_type.rb +240 -0
  32. data/lib/coderay/helpers/gzip_simple.rb +123 -0
  33. data/lib/coderay/helpers/plugin.rb +349 -0
  34. data/lib/coderay/helpers/word_list.rb +138 -0
  35. data/lib/coderay/scanner.rb +284 -0
  36. data/lib/coderay/scanners/_map.rb +23 -0
  37. data/lib/coderay/scanners/c.rb +203 -0
  38. data/lib/coderay/scanners/cpp.rb +228 -0
  39. data/lib/coderay/scanners/css.rb +210 -0
  40. data/lib/coderay/scanners/debug.rb +62 -0
  41. data/lib/coderay/scanners/delphi.rb +150 -0
  42. data/lib/coderay/scanners/diff.rb +105 -0
  43. data/lib/coderay/scanners/groovy.rb +263 -0
  44. data/lib/coderay/scanners/html.rb +182 -0
  45. data/lib/coderay/scanners/java.rb +176 -0
  46. data/lib/coderay/scanners/java/builtin_types.rb +419 -0
  47. data/lib/coderay/scanners/java_script.rb +224 -0
  48. data/lib/coderay/scanners/json.rb +112 -0
  49. data/lib/coderay/scanners/nitro_xhtml.rb +136 -0
  50. data/lib/coderay/scanners/php.rb +526 -0
  51. data/lib/coderay/scanners/plaintext.rb +21 -0
  52. data/lib/coderay/scanners/python.rb +285 -0
  53. data/lib/coderay/scanners/rhtml.rb +74 -0
  54. data/lib/coderay/scanners/ruby.rb +404 -0
  55. data/lib/coderay/scanners/ruby/patterns.rb +238 -0
  56. data/lib/coderay/scanners/scheme.rb +145 -0
  57. data/lib/coderay/scanners/sql.rb +162 -0
  58. data/lib/coderay/scanners/xml.rb +17 -0
  59. data/lib/coderay/scanners/yaml.rb +144 -0
  60. data/lib/coderay/style.rb +20 -0
  61. data/lib/coderay/styles/_map.rb +7 -0
  62. data/lib/coderay/styles/cycnus.rb +151 -0
  63. data/lib/coderay/styles/murphy.rb +132 -0
  64. data/lib/coderay/token_classes.rb +86 -0
  65. data/lib/coderay/tokens.rb +391 -0
  66. data/lib/term/ansicolor.rb +220 -0
  67. metadata +123 -0
@@ -0,0 +1,220 @@
1
+ # = Term::ANSIColor - ANSI escape sequences in Ruby
2
+ #
3
+ # == Description
4
+ #
5
+ # This library can be used to color/uncolor strings using ANSI escape sequences.
6
+ #
7
+ # == Author
8
+ #
9
+ # Florian Frank mailto:flori@ping.de
10
+ #
11
+ # == License
12
+ #
13
+ # This is free software; you can redistribute it and/or modify it under the
14
+ # terms of the GNU General Public License Version 2 as published by the Free
15
+ # Software Foundation: www.gnu.org/copyleft/gpl.html
16
+ #
17
+ # == Download
18
+ #
19
+ # The latest version of this library can be downloaded at
20
+ #
21
+ # * http://rubyforge.org/frs?group_id=391
22
+ #
23
+ # The homepage of this library is located at
24
+ #
25
+ # * http://term-ansicolor.rubyforge.org
26
+ #
27
+ # == Examples
28
+ #
29
+ # The file examples/example.rb in the source/gem-distribution shows how
30
+ # this library can be used:
31
+ # require 'term/ansicolor'
32
+ #
33
+ # # Use this trick to work around namespace cluttering that
34
+ # # happens if you just include Term::ANSIColor:
35
+ #
36
+ # class Color
37
+ # class << self
38
+ # include Term::ANSIColor
39
+ # end
40
+ # end
41
+ #
42
+ # print Color.red, Color.bold, "No Namespace cluttering:", Color.clear, "\n"
43
+ # print Color.green + "green" + Color.clear, "\n"
44
+ # print Color.on_red(Color.green("green")), "\n"
45
+ # print Color.yellow { Color.on_black { "yellow on_black" } }, "\n\n"
46
+ #
47
+ # # Or shortcut Term::ANSIColor by assignment:
48
+ # c = Term::ANSIColor
49
+ #
50
+ # print c.red, c.bold, "No Namespace cluttering (alternative):", c.clear, "\n"
51
+ # print c.green + "green" + c.clear, "\n"
52
+ # print c.on_red(c.green("green")), "\n"
53
+ # print c.yellow { c.on_black { "yellow on_black" } }, "\n\n"
54
+ #
55
+ # # Anyway, I don't define any of Term::ANSIColor's methods in this example
56
+ # # and I want to keep it short:
57
+ # include Term::ANSIColor
58
+ #
59
+ # print red, bold, "Usage as constants:", reset, "\n"
60
+ # print clear, "clear", reset, reset, "reset", reset,
61
+ # bold, "bold", reset, dark, "dark", reset,
62
+ # underscore, "underscore", reset, blink, "blink", reset,
63
+ # negative, "negative", reset, concealed, "concealed", reset, "|\n",
64
+ # black, "black", reset, red, "red", reset, green, "green", reset,
65
+ # yellow, "yellow", reset, blue, "blue", reset, magenta, "magenta", reset,
66
+ # cyan, "cyan", reset, white, "white", reset, "|\n",
67
+ # on_black, "on_black", reset, on_red, "on_red", reset,
68
+ # on_green, "on_green", reset, on_yellow, "on_yellow", reset,
69
+ # on_blue, "on_blue", reset, on_magenta, "on_magenta", reset,
70
+ # on_cyan, "on_cyan", reset, on_white, "on_white", reset, "|\n\n"
71
+ #
72
+ # print red, bold, "Usage as unary argument methods:", reset, "\n"
73
+ # print clear("clear"), reset("reset"), bold("bold"), dark("dark"),
74
+ # underscore("underscore"), blink("blink"), negative("negative"),
75
+ # concealed("concealed"), "|\n",
76
+ # black("black"), red("red"), green("green"), yellow("yellow"),
77
+ # blue("blue"), magenta("magenta"), cyan("cyan"), white("white"), "|\n",
78
+ # on_black("on_black"), on_red("on_red"), on_green("on_green"),#
79
+ # on_yellow("on_yellow"), on_blue("on_blue"), on_magenta("on_magenta"),
80
+ # on_cyan("on_cyan"), on_white("on_white"), "|\n\n"
81
+ #
82
+ # print red { bold { "Usage as block forms:" } }, "\n"
83
+ # print clear { "clear" }, reset { "reset" }, bold { "bold" },
84
+ # dark { "dark" }, underscore { "underscore" }, blink { "blink" },
85
+ # negative { "negative" }, concealed { "concealed" }, "|\n",
86
+ # black { "black" }, red { "red" }, green { "green" },
87
+ # yellow { "yellow" }, blue { "blue" }, magenta { "magenta" },
88
+ # cyan { "cyan" }, white { "white" }, "|\n",
89
+ # on_black { "on_black" }, on_red { "on_red" }, on_green { "on_green" },
90
+ # on_yellow { "on_yellow" }, on_blue { "on_blue" },
91
+ # on_magenta { "on_magenta" }, on_cyan { "on_cyan" },
92
+ # on_white { "on_white" }, "|\n\n"
93
+ #
94
+ # # Usage as Mixin into String or its Subclasses
95
+ # class String
96
+ # include Term::ANSIColor
97
+ # end
98
+ #
99
+ # print "Usage as String Mixins:".red.bold, "\n"
100
+ # print "clear".clear, "reset".reset, "bold".bold, "dark".dark,
101
+ # "underscore".underscore, "blink".blink, "negative".negative,
102
+ # "concealed".concealed, "|\n",
103
+ # "black".black, "red".red, "green".green, "yellow".yellow,
104
+ # "blue".blue, "magenta".magenta, "cyan".cyan, "white".white, "|\n",
105
+ # "on_black".on_black, "on_red".on_red, "on_green".on_green,
106
+ # "on_yellow".on_yellow, "on_blue".on_blue, "on_magenta".on_magenta,
107
+ # "on_cyan".on_cyan, "on_white".on_white, "|\n\n"
108
+ #
109
+ # symbols = Term::ANSIColor::attributes
110
+ # print red { bold { "All supported attributes = " } },
111
+ # blue { symbols.inspect }, "\n\n"
112
+ #
113
+ # print "Send symbols to strings:".send(:red).send(:bold), "\n"
114
+ # print symbols[12, 8].map { |c| c.to_s.send(c) }, "\n\n"
115
+ #
116
+ # print red { bold { "Make strings monochromatic again:" } }, "\n"
117
+ # print [ "red".red, "not red anymore".red.uncolored,
118
+ # uncolored { "not red anymore".red }, uncolored("not red anymore".red)
119
+ # ].map { |x| x + "\n" }
120
+ module Term
121
+ # The ANSIColor module can be used for namespacing and mixed into your own
122
+ # classes.
123
+ module ANSIColor
124
+ # :stopdoc:
125
+ ATTRIBUTES = [
126
+ [ :clear , 0 ],
127
+ [ :reset , 0 ], # synonym for :clear
128
+ [ :bold , 1 ],
129
+ [ :dark , 2 ],
130
+ [ :italic , 3 ], # not widely implemented
131
+ [ :underline , 4 ],
132
+ [ :underscore , 4 ], # synonym for :underline
133
+ [ :blink , 5 ],
134
+ [ :rapid_blink , 6 ], # not widely implemented
135
+ [ :negative , 7 ], # no reverse because of String#reverse
136
+ [ :concealed , 8 ],
137
+ [ :strikethrough, 9 ], # not widely implemented
138
+ [ :black , 30 ],
139
+ [ :red , 31 ],
140
+ [ :green , 32 ],
141
+ [ :yellow , 33 ],
142
+ [ :blue , 34 ],
143
+ [ :magenta , 35 ],
144
+ [ :cyan , 36 ],
145
+ [ :white , 37 ],
146
+ [ :on_black , 40 ],
147
+ [ :on_red , 41 ],
148
+ [ :on_green , 42 ],
149
+ [ :on_yellow , 43 ],
150
+ [ :on_blue , 44 ],
151
+ [ :on_magenta , 45 ],
152
+ [ :on_cyan , 46 ],
153
+ [ :on_white , 47 ],
154
+ ]
155
+
156
+ ATTRIBUTE_NAMES = ATTRIBUTES.transpose.first
157
+ # :startdoc:
158
+
159
+ # Returns true, if the coloring function of this module
160
+ # is switched on, false otherwise.
161
+ def self.coloring?
162
+ @coloring
163
+ end
164
+
165
+ # Turns the coloring on or off globally, so you can easily do
166
+ # this for example:
167
+ # Term::ANSIColor::coloring = STDOUT.isatty
168
+ def self.coloring=(val)
169
+ @coloring = val
170
+ end
171
+ self.coloring = true
172
+
173
+ ATTRIBUTES.each do |c, v|
174
+ eval %Q{
175
+ def #{c}(string = nil)
176
+ result = ''
177
+ result << "\e[#{v}m" if Term::ANSIColor.coloring?
178
+ if block_given?
179
+ result << yield
180
+ elsif string
181
+ result << string
182
+ elsif respond_to?(:to_str)
183
+ result << self
184
+ else
185
+ return result #only switch on
186
+ end
187
+ result << "\e[0m" if Term::ANSIColor.coloring?
188
+ result
189
+ end
190
+ }
191
+ end
192
+
193
+ # Regular expression that is used to scan for ANSI-sequences while
194
+ # uncoloring strings.
195
+ COLORED_REGEXP = /\e\[([34][0-7]|[0-9])m/
196
+
197
+ # Returns an uncolored version of the string, that is all
198
+ # ANSI-sequences are stripped from the string.
199
+ def uncolored(string = nil) # :yields:
200
+ if block_given?
201
+ yield.gsub(COLORED_REGEXP, '')
202
+ elsif string
203
+ string.gsub(COLORED_REGEXP, '')
204
+ elsif respond_to?(:to_str)
205
+ gsub(COLORED_REGEXP, '')
206
+ else
207
+ ''
208
+ end
209
+ end
210
+
211
+ module_function
212
+
213
+ # Returns an array of all Term::ANSIColor attributes as symbols.
214
+ def attributes
215
+ ATTRIBUTE_NAMES
216
+ end
217
+ extend self
218
+ end
219
+ end
220
+ # vim: set et sw=2 ts=2:
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: coderay-beta
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.1
5
+ platform: ruby
6
+ authors:
7
+ - murphy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-31 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: " CodeRay is a Ruby library for syntax highlighting.\n I try to make CodeRay easy to use and intuitive, but at the same time\n fully featured, complete, fast and efficient.\n\n Usage is simple:\n CodeRay.scan(code, :ruby).div\n"
17
+ email: murphy@rubychan.de
18
+ executables:
19
+ - coderay
20
+ - coderay_stylesheet
21
+ extensions: []
22
+
23
+ extra_rdoc_files:
24
+ - ./lib/README
25
+ - ./FOLDERS
26
+ files:
27
+ - ./lib/coderay/duo.rb
28
+ - ./lib/coderay/encoder.rb
29
+ - ./lib/coderay/encoders/_map.rb
30
+ - ./lib/coderay/encoders/comment_filter.rb
31
+ - ./lib/coderay/encoders/count.rb
32
+ - ./lib/coderay/encoders/debug.rb
33
+ - ./lib/coderay/encoders/div.rb
34
+ - ./lib/coderay/encoders/filter.rb
35
+ - ./lib/coderay/encoders/html/css.rb
36
+ - ./lib/coderay/encoders/html/numerization.rb
37
+ - ./lib/coderay/encoders/html/output.rb
38
+ - ./lib/coderay/encoders/html.rb
39
+ - ./lib/coderay/encoders/json.rb
40
+ - ./lib/coderay/encoders/lines_of_code.rb
41
+ - ./lib/coderay/encoders/null.rb
42
+ - ./lib/coderay/encoders/page.rb
43
+ - ./lib/coderay/encoders/span.rb
44
+ - ./lib/coderay/encoders/statistic.rb
45
+ - ./lib/coderay/encoders/term.rb
46
+ - ./lib/coderay/encoders/text.rb
47
+ - ./lib/coderay/encoders/token_class_filter.rb
48
+ - ./lib/coderay/encoders/xml.rb
49
+ - ./lib/coderay/encoders/yaml.rb
50
+ - ./lib/coderay/for_redcloth.rb
51
+ - ./lib/coderay/helpers/file_type.rb
52
+ - ./lib/coderay/helpers/gzip_simple.rb
53
+ - ./lib/coderay/helpers/plugin.rb
54
+ - ./lib/coderay/helpers/word_list.rb
55
+ - ./lib/coderay/scanner.rb
56
+ - ./lib/coderay/scanners/_map.rb
57
+ - ./lib/coderay/scanners/c.rb
58
+ - ./lib/coderay/scanners/cpp.rb
59
+ - ./lib/coderay/scanners/css.rb
60
+ - ./lib/coderay/scanners/debug.rb
61
+ - ./lib/coderay/scanners/delphi.rb
62
+ - ./lib/coderay/scanners/diff.rb
63
+ - ./lib/coderay/scanners/groovy.rb
64
+ - ./lib/coderay/scanners/html.rb
65
+ - ./lib/coderay/scanners/java/builtin_types.rb
66
+ - ./lib/coderay/scanners/java.rb
67
+ - ./lib/coderay/scanners/java_script.rb
68
+ - ./lib/coderay/scanners/json.rb
69
+ - ./lib/coderay/scanners/nitro_xhtml.rb
70
+ - ./lib/coderay/scanners/php.rb
71
+ - ./lib/coderay/scanners/plaintext.rb
72
+ - ./lib/coderay/scanners/python.rb
73
+ - ./lib/coderay/scanners/rhtml.rb
74
+ - ./lib/coderay/scanners/ruby/patterns.rb
75
+ - ./lib/coderay/scanners/ruby.rb
76
+ - ./lib/coderay/scanners/scheme.rb
77
+ - ./lib/coderay/scanners/sql.rb
78
+ - ./lib/coderay/scanners/xml.rb
79
+ - ./lib/coderay/scanners/yaml.rb
80
+ - ./lib/coderay/style.rb
81
+ - ./lib/coderay/styles/_map.rb
82
+ - ./lib/coderay/styles/cycnus.rb
83
+ - ./lib/coderay/styles/murphy.rb
84
+ - ./lib/coderay/token_classes.rb
85
+ - ./lib/coderay/tokens.rb
86
+ - ./lib/coderay.rb
87
+ - ./lib/term/ansicolor.rb
88
+ - ./lib/README
89
+ - ./LICENSE
90
+ - ./FOLDERS
91
+ has_rdoc: true
92
+ homepage: http://coderay.rubychan.de
93
+ licenses: []
94
+
95
+ post_install_message:
96
+ rdoc_options:
97
+ - -SNw2
98
+ - -mlib/README
99
+ - -a
100
+ - -t CodeRay Documentation
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: 1.8.2
108
+ version:
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: "0"
114
+ version:
115
+ requirements: []
116
+
117
+ rubyforge_project: coderay
118
+ rubygems_version: 1.3.5
119
+ signing_key:
120
+ specification_version: 3
121
+ summary: CodeRay is a fast syntax highlighter engine for many languages.
122
+ test_files: []
123
+