summaryrefslogtreecommitdiff
path: root/lib/coderay.rb
diff options
context:
space:
mode:
authorKornelius Kalnbach <murphy@rubychan.de>2011-12-27 02:39:02 +0100
committerKornelius Kalnbach <murphy@rubychan.de>2011-12-27 02:39:02 +0100
commit5c4c0065784c6420224516e13a0c50d86e792363 (patch)
treef150f672a18b306896b3db3234ec2d5bdbab42ee /lib/coderay.rb
parentb3807c5aa09901f50dca09b7927f37b1902ee32f (diff)
downloadcoderay-5c4c0065784c6420224516e13a0c50d86e792363.tar.gz
Bug #6: merge ConradIrwin's approach with korny's
Diffstat (limited to 'lib/coderay.rb')
-rw-r--r--lib/coderay.rb40
1 files changed, 18 insertions, 22 deletions
diff --git a/lib/coderay.rb b/lib/coderay.rb
index 63ec555..e54a73b 100644
--- a/lib/coderay.rb
+++ b/lib/coderay.rb
@@ -127,38 +127,34 @@ module CodeRay
$CODERAY_DEBUG ||= false
- # Assuming the rel_path is a subpath of lib/
- def self.abs_path(rel_path)
- File.join(File.dirname(__FILE__), rel_path)
- end
-
- # In order to work in environments that alter $:, we need to
- # set the absolute path when autoloading files.
- def self.autoload(const_name, rel_path)
- super const_name, abs_path(rel_path)
+ require 'coderay/version'
+
+ CODERAY_PATH = File.join File.dirname(__FILE__), 'coderay'
+
+ # Assuming the path is a subpath of lib/coderay/
+ def self.coderay_path *path
+ File.join CODERAY_PATH, *path
end
-
- require abs_path('coderay/version')
# helpers
- autoload :FileType, 'coderay/helpers/file_type'
+ autoload :FileType, coderay_path('helpers', 'file_type')
# Tokens
- autoload :Tokens, 'coderay/tokens'
- autoload :TokensProxy, 'coderay/tokens_proxy'
- autoload :TokenKinds, 'coderay/token_kinds'
+ autoload :Tokens, coderay_path('tokens')
+ autoload :TokensProxy, coderay_path('tokens_proxy')
+ autoload :TokenKinds, coderay_path('token_kinds')
# Plugin system
- autoload :PluginHost, 'coderay/helpers/plugin'
- autoload :Plugin, 'coderay/helpers/plugin'
+ autoload :PluginHost, coderay_path('helpers', 'plugin')
+ autoload :Plugin, coderay_path('helpers', 'plugin')
# Plugins
- autoload :Scanners, 'coderay/scanner'
- autoload :Encoders, 'coderay/encoder'
- autoload :Styles, 'coderay/style'
+ autoload :Scanners, coderay_path('scanner')
+ autoload :Encoders, coderay_path('encoder')
+ autoload :Styles, coderay_path('style')
- # Convenience access and reusable Encoder/Scanner pair
- autoload :Duo, 'coderay/duo'
+ # convenience access and reusable Encoder/Scanner pair
+ autoload :Duo, coderay_path('duo')
class << self