coderay 1.0.0 → 1.0.0.598.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. data/FOLDERS +49 -0
  2. data/Rakefile +6 -5
  3. data/bin/coderay +74 -190
  4. data/bin/coderay_stylesheet +4 -0
  5. data/{README_INDEX.rdoc → lib/README} +20 -10
  6. data/lib/coderay.rb +60 -62
  7. data/lib/coderay/duo.rb +55 -2
  8. data/lib/coderay/encoder.rb +39 -52
  9. data/lib/coderay/encoders/_map.rb +7 -11
  10. data/lib/coderay/encoders/comment_filter.rb +61 -0
  11. data/lib/coderay/encoders/count.rb +26 -11
  12. data/lib/coderay/encoders/debug.rb +60 -11
  13. data/lib/coderay/encoders/div.rb +8 -9
  14. data/lib/coderay/encoders/filter.rb +52 -12
  15. data/lib/coderay/encoders/html.rb +113 -106
  16. data/lib/coderay/encoders/html/css.rb +7 -2
  17. data/lib/coderay/encoders/html/numbering.rb +27 -24
  18. data/lib/coderay/encoders/html/output.rb +58 -15
  19. data/lib/coderay/encoders/json.rb +44 -37
  20. data/lib/coderay/encoders/lines_of_code.rb +56 -9
  21. data/lib/coderay/encoders/null.rb +13 -6
  22. data/lib/coderay/encoders/page.rb +8 -8
  23. data/lib/coderay/encoders/span.rb +9 -10
  24. data/lib/coderay/encoders/statistic.rb +114 -51
  25. data/lib/coderay/encoders/terminal.rb +10 -7
  26. data/lib/coderay/encoders/text.rb +36 -17
  27. data/lib/coderay/encoders/token_kind_filter.rb +58 -1
  28. data/lib/coderay/encoders/xml.rb +11 -13
  29. data/lib/coderay/encoders/yaml.rb +14 -16
  30. data/lib/coderay/for_redcloth.rb +1 -1
  31. data/lib/coderay/helpers/file_type.rb +240 -125
  32. data/lib/coderay/helpers/gzip_simple.rb +123 -0
  33. data/lib/coderay/helpers/plugin.rb +307 -241
  34. data/lib/coderay/helpers/word_list.rb +126 -65
  35. data/lib/coderay/scanner.rb +103 -153
  36. data/lib/coderay/scanners/_map.rb +16 -18
  37. data/lib/coderay/scanners/c.rb +13 -13
  38. data/lib/coderay/scanners/cpp.rb +6 -6
  39. data/lib/coderay/scanners/css.rb +48 -47
  40. data/lib/coderay/scanners/debug.rb +55 -9
  41. data/lib/coderay/scanners/delphi.rb +4 -4
  42. data/lib/coderay/scanners/diff.rb +25 -43
  43. data/lib/coderay/scanners/groovy.rb +2 -2
  44. data/lib/coderay/scanners/html.rb +30 -107
  45. data/lib/coderay/scanners/java.rb +5 -6
  46. data/lib/coderay/scanners/java/builtin_types.rb +0 -2
  47. data/lib/coderay/scanners/java_script.rb +6 -6
  48. data/lib/coderay/scanners/json.rb +6 -7
  49. data/lib/coderay/scanners/nitro_xhtml.rb +136 -0
  50. data/lib/coderay/scanners/php.rb +12 -13
  51. data/lib/coderay/scanners/plaintext.rb +26 -0
  52. data/lib/coderay/scanners/python.rb +4 -4
  53. data/lib/coderay/scanners/{erb.rb → rhtml.rb} +11 -19
  54. data/lib/coderay/scanners/ruby.rb +208 -219
  55. data/lib/coderay/scanners/ruby/patterns.rb +85 -18
  56. data/lib/coderay/scanners/scheme.rb +136 -0
  57. data/lib/coderay/scanners/sql.rb +22 -29
  58. data/lib/coderay/scanners/yaml.rb +10 -11
  59. data/lib/coderay/styles/_map.rb +2 -2
  60. data/lib/coderay/styles/alpha.rb +104 -102
  61. data/lib/coderay/styles/cycnus.rb +143 -0
  62. data/lib/coderay/styles/murphy.rb +123 -0
  63. data/lib/coderay/token_kinds.rb +86 -87
  64. data/lib/coderay/tokens.rb +169 -26
  65. data/test/functional/basic.rb +14 -200
  66. data/test/functional/examples.rb +14 -20
  67. data/test/functional/for_redcloth.rb +8 -15
  68. data/test/functional/load_plugin_scanner.rb +11 -0
  69. data/test/functional/suite.rb +6 -9
  70. data/test/functional/vhdl.rb +126 -0
  71. data/test/functional/word_list.rb +79 -0
  72. metadata +129 -107
  73. data/lib/coderay/helpers/gzip.rb +0 -41
  74. data/lib/coderay/scanners/clojure.rb +0 -217
  75. data/lib/coderay/scanners/haml.rb +0 -168
  76. data/lib/coderay/scanners/ruby/string_state.rb +0 -71
  77. data/lib/coderay/scanners/text.rb +0 -26
  78. data/lib/coderay/tokens_proxy.rb +0 -55
  79. data/lib/coderay/version.rb +0 -3
@@ -1,15 +1,11 @@
1
- # encoding: utf-8
2
1
  require 'test/unit'
3
- require File.expand_path('../../lib/assert_warning', __FILE__)
4
-
5
- $:.unshift File.expand_path('../../../lib', __FILE__)
6
2
  require 'coderay'
7
3
 
8
4
  class BasicTest < Test::Unit::TestCase
9
5
 
10
6
  def test_version
11
7
  assert_nothing_raised do
12
- assert_match(/\A\d\.\d\.\d?\z/, CodeRay::VERSION)
8
+ assert_match(/\A\d\.\d\.\d\z/, CodeRay::VERSION)
13
9
  end
14
10
  end
15
11
 
@@ -26,52 +22,28 @@ class BasicTest < Test::Unit::TestCase
26
22
  ].flatten
27
23
  def test_simple_scan
28
24
  assert_nothing_raised do
29
- assert_equal RUBY_TEST_TOKENS, CodeRay.scan(RUBY_TEST_CODE, :ruby).tokens
25
+ assert_equal RUBY_TEST_TOKENS, CodeRay.scan(RUBY_TEST_CODE, :ruby).to_ary
30
26
  end
31
27
  end
32
28
 
33
- RUBY_TEST_HTML = 'puts <span class="string"><span class="delimiter">&quot;</span>' +
34
- '<span class="content">Hello, World!</span><span class="delimiter">&quot;</span></span>'
29
+ RUBY_TEST_HTML = 'puts <span class="s"><span class="dl">&quot;</span>' +
30
+ '<span class="k">Hello, World!</span><span class="dl">&quot;</span></span>'
35
31
  def test_simple_highlight
36
32
  assert_nothing_raised do
37
33
  assert_equal RUBY_TEST_HTML, CodeRay.scan(RUBY_TEST_CODE, :ruby).html
38
34
  end
39
35
  end
40
36
 
41
- def test_scan_file
42
- CodeRay.scan_file __FILE__
43
- end
44
-
45
- def test_encode
46
- assert_equal 1, CodeRay.encode('test', :python, :count)
47
- end
48
-
49
- def test_encode_tokens
50
- assert_equal 1, CodeRay.encode_tokens(CodeRay::Tokens['test', :string], :count)
51
- end
52
-
53
- def test_encode_file
54
- assert_equal File.read(__FILE__), CodeRay.encode_file(__FILE__, :text)
55
- end
56
-
57
- def test_highlight
58
- assert_match '<pre>test</pre>', CodeRay.highlight('test', :python)
59
- end
60
-
61
- def test_highlight_file
62
- assert_match "require <span class=\"string\"><span class=\"delimiter\">'</span><span class=\"content\">test/unit</span><span class=\"delimiter\">'</span></span>\n", CodeRay.highlight_file(__FILE__)
63
- end
64
-
65
37
  def test_duo
66
38
  assert_equal(RUBY_TEST_CODE,
67
- CodeRay::Duo[:plain, :text].highlight(RUBY_TEST_CODE))
39
+ CodeRay::Duo[:plain, :plain].highlight(RUBY_TEST_CODE))
68
40
  assert_equal(RUBY_TEST_CODE,
69
- CodeRay::Duo[:plain => :text].highlight(RUBY_TEST_CODE))
41
+ CodeRay::Duo[:plain => :plain].highlight(RUBY_TEST_CODE))
70
42
  end
71
43
 
72
44
  def test_duo_stream
73
45
  assert_equal(RUBY_TEST_CODE,
74
- CodeRay::Duo[:plain, :text].highlight(RUBY_TEST_CODE, :stream => true))
46
+ CodeRay::Duo[:plain, :plain].highlight(RUBY_TEST_CODE, :stream => true))
75
47
  end
76
48
 
77
49
  def test_comment_filter
@@ -126,179 +98,21 @@ more code # and another comment, in-line.
126
98
  assert_equal 0, CodeRay.scan(rHTML, :html).lines_of_code
127
99
  assert_equal 0, CodeRay.scan(rHTML, :php).lines_of_code
128
100
  assert_equal 0, CodeRay.scan(rHTML, :yaml).lines_of_code
129
- assert_equal 4, CodeRay.scan(rHTML, :erb).lines_of_code
101
+ assert_equal 4, CodeRay.scan(rHTML, :rhtml).lines_of_code
130
102
  end
131
103
 
104
+ def test_rubygems_not_loaded
105
+ assert_equal nil, defined? Gem
106
+ end if ENV['check_rubygems'] && RUBY_VERSION < '1.9'
107
+
132
108
  def test_list_of_encoders
133
109
  assert_kind_of(Array, CodeRay::Encoders.list)
134
- assert CodeRay::Encoders.list.include?(:count)
110
+ assert CodeRay::Encoders.list.include?('count')
135
111
  end
136
112
 
137
113
  def test_list_of_scanners
138
114
  assert_kind_of(Array, CodeRay::Scanners.list)
139
- assert CodeRay::Scanners.list.include?(:text)
140
- end
141
-
142
- def test_token_kinds
143
- assert_kind_of Hash, CodeRay::TokenKinds
144
- for kind, css_class in CodeRay::TokenKinds
145
- assert_kind_of Symbol, kind
146
- if css_class != false
147
- assert_kind_of String, css_class, "TokenKinds[%p] == %p" % [kind, css_class]
148
- end
149
- end
150
- assert_equal 'reserved', CodeRay::TokenKinds[:reserved]
151
- assert_warning 'Undefined Token kind: :shibboleet' do
152
- assert_equal false, CodeRay::TokenKinds[:shibboleet]
153
- end
154
- end
155
-
156
- class Milk < CodeRay::Encoders::Encoder
157
- FILE_EXTENSION = 'cocoa'
158
- end
159
-
160
- class HoneyBee < CodeRay::Encoders::Encoder
161
- end
162
-
163
- def test_encoder_file_extension
164
- assert_nothing_raised do
165
- assert_equal 'html', CodeRay::Encoders::Page::FILE_EXTENSION
166
- assert_equal 'cocoa', Milk::FILE_EXTENSION
167
- assert_equal 'cocoa', Milk.new.file_extension
168
- assert_equal 'honeybee', HoneyBee::FILE_EXTENSION
169
- assert_equal 'honeybee', HoneyBee.new.file_extension
170
- end
171
- assert_raise NameError do
172
- HoneyBee::MISSING_CONSTANT
173
- end
174
- end
175
-
176
- def test_encoder_tokens
177
- encoder = CodeRay::Encoders::Encoder.new
178
- encoder.send :setup, {}
179
- assert_raise(ArgumentError) { encoder.token :strange, '' }
180
- encoder.token 'test', :debug
181
- end
182
-
183
- def test_encoder_deprecated_interface
184
- encoder = CodeRay::Encoders::Encoder.new
185
- encoder.send :setup, {}
186
- assert_warning 'Using old Tokens#<< interface.' do
187
- encoder << ['test', :content]
188
- end
189
- assert_raise ArgumentError do
190
- encoder << [:strange, :input]
191
- end
192
- assert_raise ArgumentError do
193
- encoder.encode_tokens [['test', :token]]
194
- end
195
- end
196
-
197
- def encoder_token_interface_deprecation_warning_given
198
- CodeRay::Encoders::Encoder.send :class_variable_get, :@@CODERAY_TOKEN_INTERFACE_DEPRECATION_WARNING_GIVEN
199
- end
200
-
201
- def test_scanner_file_extension
202
- assert_equal 'rb', CodeRay::Scanners::Ruby.file_extension
203
- assert_equal 'rb', CodeRay::Scanners::Ruby.new.file_extension
204
- assert_equal 'java', CodeRay::Scanners::Java.file_extension
205
- assert_equal 'java', CodeRay::Scanners::Java.new.file_extension
206
- end
207
-
208
- def test_scanner_lang
209
- assert_equal :ruby, CodeRay::Scanners::Ruby.lang
210
- assert_equal :ruby, CodeRay::Scanners::Ruby.new.lang
211
- assert_equal :java, CodeRay::Scanners::Java.lang
212
- assert_equal :java, CodeRay::Scanners::Java.new.lang
213
- end
214
-
215
- def test_scanner_tokenize
216
- assert_equal ['foo', :plain], CodeRay::Scanners::Plain.new.tokenize('foo')
217
- assert_equal [['foo', :plain], ['bar', :plain]], CodeRay::Scanners::Plain.new.tokenize(['foo', 'bar'])
218
- CodeRay::Scanners::Plain.new.tokenize 42
219
- end
220
-
221
- def test_scanner_tokens
222
- scanner = CodeRay::Scanners::Plain.new
223
- scanner.tokenize('foo')
224
- assert_equal ['foo', :plain], scanner.tokens
225
- scanner.string = ''
226
- assert_equal ['', :plain], scanner.tokens
227
- end
228
-
229
- def test_scanner_line_and_column
230
- scanner = CodeRay::Scanners::Plain.new "foo\nbär+quux"
231
- assert_equal 0, scanner.pos
232
- assert_equal 1, scanner.line
233
- assert_equal 1, scanner.column
234
- scanner.scan(/foo/)
235
- assert_equal 3, scanner.pos
236
- assert_equal 1, scanner.line
237
- assert_equal 4, scanner.column
238
- scanner.scan(/\n/)
239
- assert_equal 4, scanner.pos
240
- assert_equal 2, scanner.line
241
- assert_equal 1, scanner.column
242
- scanner.scan(/b/)
243
- assert_equal 5, scanner.pos
244
- assert_equal 2, scanner.line
245
- assert_equal 2, scanner.column
246
- scanner.scan(/a/)
247
- assert_equal 5, scanner.pos
248
- assert_equal 2, scanner.line
249
- assert_equal 2, scanner.column
250
- scanner.scan(/ä/)
251
- assert_equal 7, scanner.pos
252
- assert_equal 2, scanner.line
253
- assert_equal 4, scanner.column
254
- scanner.scan(/r/)
255
- assert_equal 8, scanner.pos
256
- assert_equal 2, scanner.line
257
- assert_equal 5, scanner.column
258
- end
259
-
260
- def test_scanner_use_subclasses
261
- assert_raise NotImplementedError do
262
- CodeRay::Scanners::Scanner.new
263
- end
264
- end
265
-
266
- class InvalidScanner < CodeRay::Scanners::Scanner
267
- end
268
-
269
- def test_scanner_scan_tokens
270
- assert_raise NotImplementedError do
271
- InvalidScanner.new.tokenize ''
272
- end
273
- end
274
-
275
- class RaisingScanner < CodeRay::Scanners::Scanner
276
- def scan_tokens encoder, options
277
- raise_inspect 'message', [], :initial
278
- end
279
- end
280
-
281
- def test_scanner_raise_inspect
282
- assert_raise CodeRay::Scanners::Scanner::ScanError do
283
- RaisingScanner.new.tokenize ''
284
- end
285
- end
286
-
287
- def test_scan_a_frozen_string
288
- assert_nothing_raised do
289
- CodeRay.scan RUBY_VERSION, :ruby
290
- CodeRay.scan RUBY_VERSION, :plain
291
- end
292
- end
293
-
294
- def test_scan_a_non_string
295
- assert_nothing_raised do
296
- CodeRay.scan 42, :ruby
297
- CodeRay.scan nil, :ruby
298
- CodeRay.scan self, :ruby
299
- CodeRay.encode ENV.to_hash, :ruby, :page
300
- CodeRay.highlight CodeRay, :plain
301
- end
115
+ assert CodeRay::Scanners.list.include?('plaintext')
302
116
  end
303
117
 
304
118
  end
@@ -1,6 +1,4 @@
1
1
  require 'test/unit'
2
-
3
- $:.unshift File.expand_path('../../../lib', __FILE__)
4
2
  require 'coderay'
5
3
 
6
4
  class ExamplesTest < Test::Unit::TestCase
@@ -10,7 +8,7 @@ class ExamplesTest < Test::Unit::TestCase
10
8
  div = CodeRay.scan('puts "Hello, world!"', :ruby).div
11
9
  assert_equal <<-DIV, div
12
10
  <div class="CodeRay">
13
- <div class="code"><pre>puts <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Hello, world!</span><span style="color:#710">&quot;</span></span></pre></div>
11
+ <div class="code"><pre>puts <span style="background-color:hsla(0,100%,50%,0.1)"><span style="color:#710">&quot;</span><span style="color:#D20">Hello, world!</span><span style="color:#710">&quot;</span></span></pre></div>
14
12
  </div>
15
13
  DIV
16
14
 
@@ -22,12 +20,12 @@ end
22
20
  CODE
23
21
  assert_equal <<-DIV, div
24
22
  <table class="CodeRay"><tr>
25
- <td class="line-numbers" title="double click to toggle" ondblclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"><pre><a href="#n1" name="n1">1</a>
23
+ <td class="line_numbers" title="double click to toggle" ondblclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"><pre><a href="#n1" name="n1">1</a>
26
24
  <a href="#n2" name="n2">2</a>
27
25
  <a href="#n3" name="n3">3</a>
28
26
  </pre></td>
29
- <td class="code"><pre><span style="color:#00D">5</span>.times <span style="color:#080;font-weight:bold">do</span>
30
- puts <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Hello, world!</span><span style="color:#710">'</span></span>
27
+ <td class="code"><pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"><span style="color:#00D;font-weight:bold">5</span>.times <span style="color:#080;font-weight:bold">do</span>
28
+ puts <span style="background-color:hsla(0,100%,50%,0.1)"><span style="color:#710">'</span><span style="color:#D20">Hello, world!</span><span style="color:#710">'</span></span>
31
29
  <span style="color:#080;font-weight:bold">end</span></pre></td>
32
30
  </tr></table>
33
31
  DIV
@@ -38,9 +36,9 @@ end
38
36
  <body style="background-color: white;">
39
37
 
40
38
  <table class="CodeRay"><tr>
41
- <td class="line-numbers" title="double click to toggle" ondblclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"><pre>
39
+ <td class="line_numbers" title="double click to toggle" ondblclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"><pre>
42
40
  </pre></td>
43
- <td class="code"><pre>puts <span class="string"><span class="delimiter">&quot;</span><span class="content">Hello, world!</span><span class="delimiter">&quot;</span></span></pre></td>
41
+ <td class="code"><pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }">puts <span class="s"><span class="dl">&quot;</span><span class="k">Hello, world!</span><span class="dl">&quot;</span></span></pre></td>
44
42
  </tr></table>
45
43
 
46
44
  </body>
@@ -48,8 +46,6 @@ end
48
46
 
49
47
  # keep scanned tokens for later use
50
48
  tokens = CodeRay.scan('{ "just": "an", "example": 42 }', :json)
51
- assert_kind_of CodeRay::TokensProxy, tokens
52
-
53
49
  assert_equal ["{", :operator, " ", :space, :begin_group, :key,
54
50
  "\"", :delimiter, "just", :content, "\"", :delimiter,
55
51
  :end_group, :key, ":", :operator, " ", :space,
@@ -58,8 +54,8 @@ end
58
54
  " ", :space, :begin_group, :key, "\"", :delimiter,
59
55
  "example", :content, "\"", :delimiter, :end_group, :key,
60
56
  ":", :operator, " ", :space, "42", :integer,
61
- " ", :space, "}", :operator], tokens.tokens
62
-
57
+ " ", :space, "}", :operator], tokens
58
+
63
59
  # produce a token statistic
64
60
  assert_equal <<-STATISTIC, tokens.statistic
65
61
 
@@ -69,30 +65,28 @@ Tokens 26
69
65
  Non-Whitespace 15
70
66
  Bytes Total 31
71
67
 
72
- Token Types (7):
68
+ Token Types (5):
73
69
  type count ratio size (average)
74
70
  -------------------------------------------------------------
75
71
  TOTAL 26 100.00 % 1.2
76
72
  delimiter 6 23.08 % 1.0
77
73
  operator 5 19.23 % 1.0
78
74
  space 5 19.23 % 1.0
79
- key 4 15.38 % 0.0
80
- :begin_group 3 11.54 % 0.0
81
- :end_group 3 11.54 % 0.0
75
+ begin_group 3 11.54 % 0.0
82
76
  content 3 11.54 % 4.3
83
- string 2 7.69 % 0.0
77
+ end_group 3 11.54 % 0.0
84
78
  integer 1 3.85 % 2.0
85
79
 
86
80
  STATISTIC
87
81
 
88
82
  # count the tokens
89
- assert_equal 26, tokens.count
83
+ assert_equal 26, tokens.count # => 26
90
84
 
91
85
  # produce a HTML div, but with CSS classes
92
86
  div = tokens.div(:css => :class)
93
87
  assert_equal <<-DIV, div
94
88
  <div class="CodeRay">
95
- <div class="code"><pre>{ <span class="key"><span class="delimiter">&quot;</span><span class="content">just</span><span class="delimiter">&quot;</span></span>: <span class="string"><span class="delimiter">&quot;</span><span class="content">an</span><span class="delimiter">&quot;</span></span>, <span class="key"><span class="delimiter">&quot;</span><span class="content">example</span><span class="delimiter">&quot;</span></span>: <span class="integer">42</span> }</pre></div>
89
+ <div class="code"><pre>{ <span class="ke"><span class="dl">&quot;</span><span class="k">just</span><span class="dl">&quot;</span></span>: <span class="s"><span class="dl">&quot;</span><span class="k">an</span><span class="dl">&quot;</span></span>, <span class="ke"><span class="dl">&quot;</span><span class="k">example</span><span class="dl">&quot;</span></span>: <span class="i">42</span> }</pre></div>
96
90
  </div>
97
91
  DIV
98
92
 
@@ -122,7 +116,7 @@ Token Types (7):
122
116
  div = ruby_highlighter.encode('puts "Hello, world!"')
123
117
  assert_equal <<-DIV, div
124
118
  <div class="CodeRay">
125
- <div class="code"><pre>puts <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Hello, world!</span><span style="color:#710">&quot;</span></span></pre></div>
119
+ <div class="code"><pre>puts <span style="background-color:hsla(0,100%,50%,0.1)"><span style="color:#710">&quot;</span><span style="color:#D20">Hello, world!</span><span style="color:#710">&quot;</span></span></pre></div>
126
120
  </div>
127
121
  DIV
128
122
  end
@@ -1,7 +1,5 @@
1
1
  require 'test/unit'
2
- require File.expand_path('../../lib/assert_warning', __FILE__)
3
-
4
- $:.unshift File.expand_path('../../../lib', __FILE__)
2
+ $:.unshift 'lib'
5
3
  require 'coderay'
6
4
 
7
5
  begin
@@ -10,18 +8,17 @@ begin
10
8
  require 'redcloth'
11
9
  rescue LoadError
12
10
  warn 'RedCloth not found - skipping for_redcloth tests.'
13
- undef RedCloth if defined? RedCloth
14
11
  end
15
12
 
16
13
  class BasicTest < Test::Unit::TestCase
17
14
 
18
15
  def test_for_redcloth
19
16
  require 'coderay/for_redcloth'
20
- assert_equal "<p><span lang=\"ruby\" class=\"CodeRay\">puts <span style=\"background-color:hsla(0,100%,50%,0.05)\"><span style=\"color:#710\">&quot;</span><span style=\"color:#D20\">Hello, World!</span><span style=\"color:#710\">&quot;</span></span></span></p>",
17
+ assert_equal "<p><span lang=\"ruby\" class=\"CodeRay\">puts <span style=\"background-color:hsla(0,100%,50%,0.1)\"><span style=\"color:#710\">&quot;</span><span style=\"color:#D20\">Hello, World!</span><span style=\"color:#710\">&quot;</span></span></span></p>",
21
18
  RedCloth.new('@[ruby]puts "Hello, World!"@').to_html
22
19
  assert_equal <<-BLOCKCODE.chomp,
23
20
  <div lang="ruby" class="CodeRay">
24
- <div class="code"><pre>puts <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Hello, World!</span><span style="color:#710">&quot;</span></span></pre></div>
21
+ <div class="code"><pre>puts <span style="background-color:hsla(0,100%,50%,0.1)"><span style="color:#710">&quot;</span><span style="color:#D20">Hello, World!</span><span style="color:#710">&quot;</span></span></pre></div>
25
22
  </div>
26
23
  BLOCKCODE
27
24
  RedCloth.new('bc[ruby]. puts "Hello, World!"').to_html
@@ -66,19 +63,15 @@ class BasicTest < Test::Unit::TestCase
66
63
  # See http://jgarber.lighthouseapp.com/projects/13054/tickets/124-code-markup-does-not-allow-brackets.
67
64
  def test_for_redcloth_false_positive
68
65
  require 'coderay/for_redcloth'
69
- assert_warning 'CodeRay::Scanners could not load plugin :project; falling back to :text' do
70
- assert_equal '<p><code>[project]_dff.skjd</code></p>',
71
- RedCloth.new('@[project]_dff.skjd@').to_html
72
- end
66
+ assert_equal '<p><code>[project]_dff.skjd</code></p>',
67
+ RedCloth.new('@[project]_dff.skjd@').to_html
73
68
  # false positive, but expected behavior / known issue
74
69
  assert_equal "<p><span lang=\"ruby\" class=\"CodeRay\">_dff.skjd</span></p>",
75
70
  RedCloth.new('@[ruby]_dff.skjd@').to_html
76
- assert_warning 'CodeRay::Scanners could not load plugin :project; falling back to :text' do
77
- assert_equal <<-BLOCKCODE.chomp,
71
+ assert_equal <<-BLOCKCODE.chomp,
78
72
  <pre><code>[project]_dff.skjd</code></pre>
79
- BLOCKCODE
80
- RedCloth.new('bc. [project]_dff.skjd').to_html
81
- end
73
+ BLOCKCODE
74
+ RedCloth.new('bc. [project]_dff.skjd').to_html
82
75
  end
83
76
 
84
77
  end if defined? RedCloth
@@ -0,0 +1,11 @@
1
+ require 'test/unit'
2
+ require 'coderay'
3
+
4
+ class PluginScannerTest < Test::Unit::TestCase
5
+
6
+ def test_load
7
+ require File.join(File.dirname(__FILE__), 'vhdl')
8
+ assert_equal 'VHDL', CodeRay.scanner(:vhdl).class.name
9
+ end
10
+
11
+ end
@@ -1,15 +1,12 @@
1
1
  require 'test/unit'
2
2
 
3
- $VERBOSE = $CODERAY_DEBUG = true
4
- $:.unshift File.expand_path('../../../lib', __FILE__)
5
- require 'coderay'
6
-
7
- mydir = File.dirname(__FILE__)
8
- suite = Dir[File.join(mydir, '*.rb')].
9
- map { |tc| File.basename(tc).sub(/\.rb$/, '') } - %w'suite for_redcloth'
3
+ MYDIR = File.dirname(__FILE__)
10
4
 
11
- puts "Running basic CodeRay #{CodeRay::VERSION} tests: #{suite.join(', ')}"
5
+ $:.unshift 'lib'
6
+ require 'coderay'
7
+ puts "Running basic CodeRay #{CodeRay::VERSION} tests..."
12
8
 
9
+ suite = %w(basic examples load_plugin_scanner word_list)
13
10
  for test_case in suite
14
- load File.join(mydir, test_case + '.rb')
11
+ load File.join(MYDIR, test_case + '.rb')
15
12
  end