File tree Expand file tree Collapse file tree 5 files changed +19
-8
lines changed Expand file tree Collapse file tree 5 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,18 @@ module CodeRay
127
127
128
128
$CODERAY_DEBUG ||= false
129
129
130
- require 'coderay/version'
130
+ # Assuming the rel_path is a subpath of lib/
131
+ def self . abs_path ( rel_path )
132
+ File . join ( File . dirname ( __FILE__ ) , rel_path )
133
+ end
134
+
135
+ # In order to work in environments that alter $:, we need to
136
+ # set the absolute path when autoloading files.
137
+ def self . autoload ( const_name , rel_path )
138
+ super const_name , abs_path ( rel_path )
139
+ end
140
+
141
+ require abs_path ( 'coderay/version' )
131
142
132
143
# helpers
133
144
autoload :FileType , 'coderay/helpers/file_type'
Original file line number Diff line number Diff line change @@ -109,9 +109,9 @@ class HTML < Encoder
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 . abs_path ( 'coderay/encoders/html/output' )
113
+ autoload :CSS , CodeRay . abs_path ( 'coderay/encoders/html/css' )
114
+ autoload :Numbering , CodeRay . abs_path ( 'coderay/encoders/html/numbering' )
115
115
116
116
attr_reader :css
117
117
Original file line number Diff line number Diff line change @@ -320,4 +320,4 @@ def scan_rest
320
320
end
321
321
322
322
end
323
- end
323
+ end
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ class Java < Scanner
6
6
7
7
register_for :java
8
8
9
- autoload :BuiltinTypes , 'coderay/scanners/java/builtin_types'
9
+ autoload :BuiltinTypes , CodeRay . abs_path ( 'coderay/scanners/java/builtin_types' )
10
10
11
11
# http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html
12
12
KEYWORDS = %w[
Original file line number Diff line number Diff line change @@ -13,8 +13,8 @@ class Ruby < Scanner
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 . abs_path ( 'coderay/scanners/ruby/patterns' )
17
+ autoload :StringState , CodeRay . abs_path ( 'coderay/scanners/ruby/string_state' )
18
18
19
19
def interpreted_string_state
20
20
StringState . new :string , true , '"'
You can’t perform that action at this time.
0 commit comments