Skip to content

Commit 2afe23a

Browse files
committed
Merge branch 'master' into multiline-inline-diff
Conflicts: coderay.gemspec
2 parents c044a7a + 9c3837e commit 2afe23a

File tree

16 files changed

+64
-113
lines changed

16 files changed

+64
-113
lines changed

Changes.textile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ p=. _This files lists all changes in the CodeRay library since the 0.9.8 release
44

55
{{toc}}
66

7+
h2. Changes in 1.0.5
8+
9+
Fixes:
10+
11+
* @autoload@ calls do not depend on @coderay/lib@ being in the load path (GitHub issue #6; thanks to tvon, banister, envygeeks, and ConradIrwin)
12+
* avoid dark blue as terminal color (GitHub issue #9; thanks to shevegen)
13+
714
h2. Changes in 1.0.4
815

916
Fixes in the CSS scanner:

FOLDERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Run <code>rake bench</code> to perform an example benchmark.
1717
Executional files for CodeRay.
1818

1919
coderay:: The CodeRay executable.
20-
coderay_stylesheet:: Prints the default stylesheet.
2120

2221
== demo - Demos and functional tests
2322

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ group :development do
1010
gem "rake", "~> 0.9.2"
1111
gem "RedCloth", RUBY_PLATFORM == 'java' ? "= 4.2.7" : ">= 4.0.3"
1212
gem "term-ansicolor"
13-
gem "shoulda-context", "= 1.0.0.beta1" if RUBY_VERSION >= '1.8.7'
13+
gem "shoulda-context", "~> 1.0.0" if RUBY_VERSION >= '1.8.7'
1414
gem "json" unless RUBY_VERSION >= '1.9.1'
1515
gem "rdoc" if RUBY_VERSION >= '1.8.7'
1616
end

IDEA

Lines changed: 0 additions & 30 deletions
This file was deleted.

TODO

Lines changed: 0 additions & 47 deletions
This file was deleted.

coderay.gemspec

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ Gem::Specification.new do |s|
99
s.version = CodeRay::VERSION
1010
else
1111
# thanks to @Argorak for this solution
12-
revision = 134 + (`git log --oneline | wc -l`.to_i)
13-
s.version = "#{CodeRay::VERSION}.#{revision}rc1"
12+
# revision = 134 + (`git log --oneline | wc -l`.to_i)
13+
# s.version = "#{CodeRay::VERSION}.#{revision}rc1"
14+
s.version = "#{CodeRay::VERSION}.rc1"
15+
>>>>>>> master
1416
end
1517

1618
s.authors = ['Kornelius Kalnbach']

lib/coderay.rb

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,27 +127,34 @@ module CodeRay
127127

128128
$CODERAY_DEBUG ||= false
129129

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')
131138

132139
# helpers
133-
autoload :FileType, 'coderay/helpers/file_type'
140+
autoload :FileType, coderay_path('helpers', 'file_type')
134141

135142
# 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')
139146

140147
# 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')
143150

144151
# 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')
148155

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')
151158

152159
class << self
153160

lib/coderay/encoders/html.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ class HTML < Encoder
109109
:hint => false,
110110
}
111111

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')
115115

116116
attr_reader :css
117117

lib/coderay/encoders/terminal.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ class Terminal < Encoder
2424
:attribute_value => '31',
2525
:binary => '1;35',
2626
:char => {
27-
:self => '36', :delimiter => '34'
27+
:self => '36', :delimiter => '1;34'
2828
},
2929
:class => '1;35',
3030
:class_variable => '36',
3131
:color => '32',
3232
:comment => '37',
33-
:complex => '34',
34-
:constant => ['34', '4'],
33+
:complex => '1;34',
34+
:constant => ['1;34', '4'],
3535
:decoration => '35',
3636
:definition => '1;32',
3737
:directive => ['32', '4'],
@@ -56,7 +56,7 @@ class Terminal < Encoder
5656
:predefined_type => '1;30',
5757
:predefined => ['4', '1;34'],
5858
:preprocessor => '36',
59-
:pseudo_class => '34',
59+
:pseudo_class => '1;34',
6060
:regexp => {
6161
:self => '31',
6262
:content => '31',
@@ -77,10 +77,10 @@ class Terminal < Encoder
7777
:delimiter => '1;32',
7878
},
7979
:symbol => '1;32',
80-
:tag => '34',
80+
:tag => '1;34',
8181
:type => '1;34',
8282
:value => '36',
83-
:variable => '34',
83+
:variable => '1;34',
8484

8585
:insert => '42',
8686
:delete => '41',

lib/coderay/scanner.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
require 'strscan'
33

44
module CodeRay
5-
6-
autoload :WordList, 'coderay/helpers/word_list'
5+
6+
autoload :WordList, coderay_path('helpers', 'word_list')
77

88
# = Scanners
99
#
@@ -320,4 +320,4 @@ def scan_rest
320320
end
321321

322322
end
323-
end
323+
end

lib/coderay/scanners/diff.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ class Diff < Scanner
1616

1717
protected
1818

19-
require 'coderay/helpers/file_type'
20-
2119
def scan_tokens encoder, options
2220

2321
line_kind = nil
@@ -50,7 +48,7 @@ def scan_tokens encoder, options
5048
if match = scan(/.*?(?=$|[\t\n\x00]| \(revision)/)
5149
encoder.text_token match, :filename
5250
if options[:highlight_code] && match != '/dev/null'
53-
file_type = FileType.fetch(match, :text)
51+
file_type = CodeRay::FileType.fetch(match, :text)
5452
file_type = :text if file_type == :diff
5553
content_scanner = scanners[file_type]
5654
content_scanner_entry_state = nil

lib/coderay/scanners/java.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Java < Scanner
66

77
register_for :java
88

9-
autoload :BuiltinTypes, 'coderay/scanners/java/builtin_types'
9+
autoload :BuiltinTypes, CodeRay.coderay_path('scanners', 'java', 'builtin_types')
1010

1111
# http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html
1212
KEYWORDS = %w[

lib/coderay/scanners/ruby.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class Ruby < Scanner
1313
register_for :ruby
1414
file_extension 'rb'
1515

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')
1818

1919
def interpreted_string_state
2020
StringState.new :string, true, '"'

lib/coderay/tokens.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module CodeRay
22

33
# GZip library for writing and reading token dumps.
4-
autoload :GZip, 'coderay/helpers/gzip'
4+
autoload :GZip, coderay_path('helpers', 'gzip')
55

66
# = Tokens TODO: Rewrite!
77
#

test/functional/basic.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@ def test_version
1313
end
1414
end
1515

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+
1632
RUBY_TEST_CODE = 'puts "Hello, World!"'
1733

1834
RUBY_TEST_TOKENS = [

test/functional/examples.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ def test_examples
9797
DIV
9898

9999
# highlight a file (HTML div); guess the file type base on the extension
100-
require 'coderay/helpers/file_type'
101100
assert_equal :ruby, CodeRay::FileType[__FILE__]
102101

103102
# get a new scanner for Python

0 commit comments

Comments
 (0)