diff options
Diffstat (limited to 'lib/coderay.rb')
-rw-r--r-- | lib/coderay.rb | 40 |
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 |