diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/coderay.rb | 31 | ||||
-rw-r--r-- | lib/coderay/encoders/html.rb | 6 | ||||
-rw-r--r-- | lib/coderay/encoders/terminal.rb | 12 | ||||
-rw-r--r-- | lib/coderay/scanner.rb | 6 | ||||
-rw-r--r-- | lib/coderay/scanners/diff.rb | 4 | ||||
-rw-r--r-- | lib/coderay/scanners/java.rb | 2 | ||||
-rw-r--r-- | lib/coderay/scanners/ruby.rb | 4 | ||||
-rw-r--r-- | lib/coderay/tokens.rb | 2 |
8 files changed, 36 insertions, 31 deletions
diff --git a/lib/coderay.rb b/lib/coderay.rb index c897220..876d770 100644 --- a/lib/coderay.rb +++ b/lib/coderay.rb @@ -127,27 +127,34 @@ module CodeRay $CODERAY_DEBUG ||= false - 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 coderay_path('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 diff --git a/lib/coderay/encoders/html.rb b/lib/coderay/encoders/html.rb index 60dfad1..c32dbd1 100644 --- a/lib/coderay/encoders/html.rb +++ b/lib/coderay/encoders/html.rb @@ -109,9 +109,9 @@ module Encoders :hint => false, } - autoload :Output, 'coderay/encoders/html/output' - autoload :CSS, 'coderay/encoders/html/css' - autoload :Numbering, 'coderay/encoders/html/numbering' + autoload :Output, CodeRay.coderay_path('encoders', 'html', 'output') + autoload :CSS, CodeRay.coderay_path('encoders', 'html', 'css') + autoload :Numbering, CodeRay.coderay_path('encoders', 'html', 'numbering') attr_reader :css diff --git a/lib/coderay/encoders/terminal.rb b/lib/coderay/encoders/terminal.rb index 15c8a52..005032d 100644 --- a/lib/coderay/encoders/terminal.rb +++ b/lib/coderay/encoders/terminal.rb @@ -24,14 +24,14 @@ module CodeRay :attribute_value => '31', :binary => '1;35', :char => { - :self => '36', :delimiter => '34' + :self => '36', :delimiter => '1;34' }, :class => '1;35', :class_variable => '36', :color => '32', :comment => '37', - :complex => '34', - :constant => ['34', '4'], + :complex => '1;34', + :constant => ['1;34', '4'], :decoration => '35', :definition => '1;32', :directive => ['32', '4'], @@ -56,7 +56,7 @@ module CodeRay :predefined_type => '1;30', :predefined => ['4', '1;34'], :preprocessor => '36', - :pseudo_class => '34', + :pseudo_class => '1;34', :regexp => { :self => '31', :content => '31', @@ -77,10 +77,10 @@ module CodeRay :delimiter => '1;32', }, :symbol => '1;32', - :tag => '34', + :tag => '1;34', :type => '1;34', :value => '36', - :variable => '34', + :variable => '1;34', :insert => '42', :delete => '41', diff --git a/lib/coderay/scanner.rb b/lib/coderay/scanner.rb index 7ecbe4f..907cf00 100644 --- a/lib/coderay/scanner.rb +++ b/lib/coderay/scanner.rb @@ -2,8 +2,8 @@ require 'strscan' module CodeRay - - autoload :WordList, 'coderay/helpers/word_list' + + autoload :WordList, coderay_path('helpers', 'word_list') # = Scanners # @@ -320,4 +320,4 @@ surrounding code: end end -end
\ No newline at end of file +end diff --git a/lib/coderay/scanners/diff.rb b/lib/coderay/scanners/diff.rb index b890ed5..38efaf4 100644 --- a/lib/coderay/scanners/diff.rb +++ b/lib/coderay/scanners/diff.rb @@ -16,8 +16,6 @@ module Scanners protected - require 'coderay/helpers/file_type' - def scan_tokens encoder, options line_kind = nil @@ -50,7 +48,7 @@ module Scanners if match = scan(/.*?(?=$|[\t\n\x00]| \(revision)/) encoder.text_token match, :filename if options[:highlight_code] && match != '/dev/null' - file_type = FileType.fetch(match, :text) + file_type = CodeRay::FileType.fetch(match, :text) file_type = :text if file_type == :diff content_scanner = scanners[file_type] content_scanner_entry_state = nil diff --git a/lib/coderay/scanners/java.rb b/lib/coderay/scanners/java.rb index d3502e3..c1490ac 100644 --- a/lib/coderay/scanners/java.rb +++ b/lib/coderay/scanners/java.rb @@ -6,7 +6,7 @@ module Scanners register_for :java - autoload :BuiltinTypes, 'coderay/scanners/java/builtin_types' + autoload :BuiltinTypes, CodeRay.coderay_path('scanners', 'java', 'builtin_types') # http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html KEYWORDS = %w[ diff --git a/lib/coderay/scanners/ruby.rb b/lib/coderay/scanners/ruby.rb index 4244ab7..2be98a6 100644 --- a/lib/coderay/scanners/ruby.rb +++ b/lib/coderay/scanners/ruby.rb @@ -13,8 +13,8 @@ module Scanners register_for :ruby file_extension 'rb' - autoload :Patterns, 'coderay/scanners/ruby/patterns' - autoload :StringState, 'coderay/scanners/ruby/string_state' + autoload :Patterns, CodeRay.coderay_path('scanners', 'ruby', 'patterns') + autoload :StringState, CodeRay.coderay_path('scanners', 'ruby', 'string_state') def interpreted_string_state StringState.new :string, true, '"' diff --git a/lib/coderay/tokens.rb b/lib/coderay/tokens.rb index 045cf4a..c747017 100644 --- a/lib/coderay/tokens.rb +++ b/lib/coderay/tokens.rb @@ -1,7 +1,7 @@ module CodeRay # GZip library for writing and reading token dumps. - autoload :GZip, 'coderay/helpers/gzip' + autoload :GZip, coderay_path('helpers', 'gzip') # = Tokens TODO: Rewrite! # |