coderay 1.0.4 → 1.0.5.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -127,27 +127,34 @@ module CodeRay
127
127
 
128
128
  $CODERAY_DEBUG ||= false
129
129
 
130
- require 'coderay/version'
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, 'coderay/helpers/file_type'
140
+ autoload :FileType, coderay_path('helpers', 'file_type')
134
141
 
135
142
  # Tokens
136
- autoload :Tokens, 'coderay/tokens'
137
- autoload :TokensProxy, 'coderay/tokens_proxy'
138
- autoload :TokenKinds, 'coderay/token_kinds'
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, 'coderay/helpers/plugin'
142
- autoload :Plugin, 'coderay/helpers/plugin'
148
+ autoload :PluginHost, coderay_path('helpers', 'plugin')
149
+ autoload :Plugin, coderay_path('helpers', 'plugin')
143
150
 
144
151
  # Plugins
145
- autoload :Scanners, 'coderay/scanner'
146
- autoload :Encoders, 'coderay/encoder'
147
- autoload :Styles, 'coderay/style'
152
+ autoload :Scanners, coderay_path('scanner')
153
+ autoload :Encoders, coderay_path('encoder')
154
+ autoload :Styles, coderay_path('style')
148
155
 
149
- # Convenience access and reusable Encoder/Scanner pair
150
- autoload :Duo, 'coderay/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, 'coderay/encoders/html/output'
113
- autoload :CSS, 'coderay/encoders/html/css'
114
- autoload :Numbering, 'coderay/encoders/html/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',
@@ -2,8 +2,8 @@
2
2
  require 'strscan'
3
3
 
4
4
  module CodeRay
5
-
6
- autoload :WordList, 'coderay/helpers/word_list'
5
+
6
+ autoload :WordList, coderay_path('helpers', 'word_list')
7
7
 
8
8
  # = Scanners
9
9
  #
@@ -320,4 +320,4 @@ surrounding code:
320
320
  end
321
321
 
322
322
  end
323
- end
323
+ end
@@ -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, 'coderay/scanners/java/builtin_types'
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, 'coderay/scanners/ruby/patterns'
17
- autoload :StringState, 'coderay/scanners/ruby/string_state'
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, '"'
@@ -1,7 +1,7 @@
1
1
  module CodeRay
2
2
 
3
3
  # GZip library for writing and reading token dumps.
4
- autoload :GZip, 'coderay/helpers/gzip'
4
+ autoload :GZip, coderay_path('helpers', 'gzip')
5
5
 
6
6
  # = Tokens TODO: Rewrite!
7
7
  #
@@ -1,3 +1,3 @@
1
1
  module CodeRay
2
- VERSION = '1.0.4'
2
+ VERSION = '1.0.5'
3
3
  end
@@ -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 = [
@@ -97,7 +97,6 @@ Token Types (7):
97
97
  DIV
98
98
 
99
99
  # highlight a file (HTML div); guess the file type base on the extension
100
- require 'coderay/helpers/file_type'
101
100
  assert_equal :ruby, CodeRay::FileType[__FILE__]
102
101
 
103
102
  # get a new scanner for Python
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.4
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-11-02 00:00:00.000000000 Z
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: '0'
115
+ version: 1.3.1
116
116
  requirements: []
117
117
  rubyforge_project: coderay
118
- rubygems_version: 1.8.10
118
+ rubygems_version: 1.8.13
119
119
  signing_key:
120
120
  specification_version: 3
121
121
  summary: Fast syntax highlighting for selected languages.