coderay 1.0.4 → 1.0.5.rc1
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.
- data/lib/coderay.rb +19 -12
- data/lib/coderay/encoders/html.rb +3 -3
- data/lib/coderay/encoders/terminal.rb +6 -6
- data/lib/coderay/scanner.rb +3 -3
- data/lib/coderay/scanners/diff.rb +1 -3
- data/lib/coderay/scanners/java.rb +1 -1
- data/lib/coderay/scanners/ruby.rb +2 -2
- data/lib/coderay/tokens.rb +1 -1
- data/lib/coderay/version.rb +1 -1
- data/test/functional/basic.rb +16 -0
- data/test/functional/examples.rb +0 -1
- metadata +6 -6
data/lib/coderay.rb
CHANGED
@@ -127,27 +127,34 @@ module CodeRay
|
|
127
127
|
|
128
128
|
$CODERAY_DEBUG ||= false
|
129
129
|
|
130
|
-
|
130
|
+
CODERAY_PATH = File.join File.dirname(__FILE__), 'coderay'
|
131
|
+
|
132
|
+
# Assuming the path is a subpath of lib/coderay/
|
133
|
+
def self.coderay_path *path
|
134
|
+
File.join CODERAY_PATH, *path
|
135
|
+
end
|
136
|
+
|
137
|
+
require coderay_path('version')
|
131
138
|
|
132
139
|
# helpers
|
133
|
-
autoload :FileType, '
|
140
|
+
autoload :FileType, coderay_path('helpers', 'file_type')
|
134
141
|
|
135
142
|
# Tokens
|
136
|
-
autoload :Tokens,
|
137
|
-
autoload :TokensProxy, '
|
138
|
-
autoload :TokenKinds,
|
143
|
+
autoload :Tokens, coderay_path('tokens')
|
144
|
+
autoload :TokensProxy, coderay_path('tokens_proxy')
|
145
|
+
autoload :TokenKinds, coderay_path('token_kinds')
|
139
146
|
|
140
147
|
# Plugin system
|
141
|
-
autoload :PluginHost, '
|
142
|
-
autoload :Plugin, '
|
148
|
+
autoload :PluginHost, coderay_path('helpers', 'plugin')
|
149
|
+
autoload :Plugin, coderay_path('helpers', 'plugin')
|
143
150
|
|
144
151
|
# Plugins
|
145
|
-
autoload :Scanners,
|
146
|
-
autoload :Encoders,
|
147
|
-
autoload :Styles,
|
152
|
+
autoload :Scanners, coderay_path('scanner')
|
153
|
+
autoload :Encoders, coderay_path('encoder')
|
154
|
+
autoload :Styles, coderay_path('style')
|
148
155
|
|
149
|
-
#
|
150
|
-
autoload :Duo,
|
156
|
+
# convenience access and reusable Encoder/Scanner pair
|
157
|
+
autoload :Duo, coderay_path('duo')
|
151
158
|
|
152
159
|
class << self
|
153
160
|
|
@@ -109,9 +109,9 @@ module Encoders
|
|
109
109
|
:hint => false,
|
110
110
|
}
|
111
111
|
|
112
|
-
autoload :Output, '
|
113
|
-
autoload :CSS, '
|
114
|
-
autoload :Numbering, '
|
112
|
+
autoload :Output, CodeRay.coderay_path('encoders', 'html', 'output')
|
113
|
+
autoload :CSS, CodeRay.coderay_path('encoders', 'html', 'css')
|
114
|
+
autoload :Numbering, CodeRay.coderay_path('encoders', 'html', 'numbering')
|
115
115
|
|
116
116
|
attr_reader :css
|
117
117
|
|
@@ -24,14 +24,14 @@ module CodeRay
|
|
24
24
|
:attribute_value => '31',
|
25
25
|
:binary => '1;35',
|
26
26
|
:char => {
|
27
|
-
:self => '36', :delimiter => '34'
|
27
|
+
:self => '36', :delimiter => '1;34'
|
28
28
|
},
|
29
29
|
:class => '1;35',
|
30
30
|
:class_variable => '36',
|
31
31
|
:color => '32',
|
32
32
|
:comment => '37',
|
33
|
-
:complex => '34',
|
34
|
-
:constant => ['34', '4'],
|
33
|
+
:complex => '1;34',
|
34
|
+
:constant => ['1;34', '4'],
|
35
35
|
:decoration => '35',
|
36
36
|
:definition => '1;32',
|
37
37
|
:directive => ['32', '4'],
|
@@ -56,7 +56,7 @@ module CodeRay
|
|
56
56
|
:predefined_type => '1;30',
|
57
57
|
:predefined => ['4', '1;34'],
|
58
58
|
:preprocessor => '36',
|
59
|
-
:pseudo_class => '34',
|
59
|
+
:pseudo_class => '1;34',
|
60
60
|
:regexp => {
|
61
61
|
:self => '31',
|
62
62
|
:content => '31',
|
@@ -77,10 +77,10 @@ module CodeRay
|
|
77
77
|
:delimiter => '1;32',
|
78
78
|
},
|
79
79
|
:symbol => '1;32',
|
80
|
-
:tag => '34',
|
80
|
+
:tag => '1;34',
|
81
81
|
:type => '1;34',
|
82
82
|
:value => '36',
|
83
|
-
:variable => '34',
|
83
|
+
:variable => '1;34',
|
84
84
|
|
85
85
|
:insert => '42',
|
86
86
|
:delete => '41',
|
data/lib/coderay/scanner.rb
CHANGED
@@ -16,8 +16,6 @@ module Scanners
|
|
16
16
|
|
17
17
|
protected
|
18
18
|
|
19
|
-
require 'coderay/helpers/file_type'
|
20
|
-
|
21
19
|
def scan_tokens encoder, options
|
22
20
|
|
23
21
|
line_kind = nil
|
@@ -50,7 +48,7 @@ module Scanners
|
|
50
48
|
if match = scan(/.*?(?=$|[\t\n\x00]| \(revision)/)
|
51
49
|
encoder.text_token match, :filename
|
52
50
|
if options[:highlight_code] && match != '/dev/null'
|
53
|
-
file_type = FileType.fetch(match, :text)
|
51
|
+
file_type = CodeRay::FileType.fetch(match, :text)
|
54
52
|
file_type = :text if file_type == :diff
|
55
53
|
content_scanner = scanners[file_type]
|
56
54
|
content_scanner_entry_state = nil
|
@@ -6,7 +6,7 @@ module Scanners
|
|
6
6
|
|
7
7
|
register_for :java
|
8
8
|
|
9
|
-
autoload :BuiltinTypes, '
|
9
|
+
autoload :BuiltinTypes, CodeRay.coderay_path('scanners', 'java', 'builtin_types')
|
10
10
|
|
11
11
|
# http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html
|
12
12
|
KEYWORDS = %w[
|
@@ -13,8 +13,8 @@ module Scanners
|
|
13
13
|
register_for :ruby
|
14
14
|
file_extension 'rb'
|
15
15
|
|
16
|
-
autoload :Patterns, '
|
17
|
-
autoload :StringState, '
|
16
|
+
autoload :Patterns, CodeRay.coderay_path('scanners', 'ruby', 'patterns')
|
17
|
+
autoload :StringState, CodeRay.coderay_path('scanners', 'ruby', 'string_state')
|
18
18
|
|
19
19
|
def interpreted_string_state
|
20
20
|
StringState.new :string, true, '"'
|
data/lib/coderay/tokens.rb
CHANGED
data/lib/coderay/version.rb
CHANGED
data/test/functional/basic.rb
CHANGED
@@ -13,6 +13,22 @@ class BasicTest < Test::Unit::TestCase
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
def with_empty_load_path
|
17
|
+
old_load_path = $:.dup
|
18
|
+
$:.clear
|
19
|
+
yield
|
20
|
+
ensure
|
21
|
+
$:.replace old_load_path
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_autoload
|
25
|
+
with_empty_load_path do
|
26
|
+
assert_nothing_raised do
|
27
|
+
CodeRay::Scanners::Java::BuiltinTypes
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
16
32
|
RUBY_TEST_CODE = 'puts "Hello, World!"'
|
17
33
|
|
18
34
|
RUBY_TEST_TOKENS = [
|
data/test/functional/examples.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coderay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.5.rc1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kornelius Kalnbach
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-12-27 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Fast and easy syntax highlighting for selected languages, written in
|
15
15
|
Ruby. Comes with RedCloth integration and LOC counter.
|
@@ -110,12 +110,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
111
|
none: false
|
112
112
|
requirements:
|
113
|
-
- - ! '
|
113
|
+
- - ! '>'
|
114
114
|
- !ruby/object:Gem::Version
|
115
|
-
version:
|
115
|
+
version: 1.3.1
|
116
116
|
requirements: []
|
117
117
|
rubyforge_project: coderay
|
118
|
-
rubygems_version: 1.8.
|
118
|
+
rubygems_version: 1.8.13
|
119
119
|
signing_key:
|
120
120
|
specification_version: 3
|
121
121
|
summary: Fast syntax highlighting for selected languages.
|