coderay 1.0.0 → 1.0.0.598.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/FOLDERS +49 -0
- data/Rakefile +6 -5
- data/bin/coderay +74 -190
- data/bin/coderay_stylesheet +4 -0
- data/{README_INDEX.rdoc → lib/README} +20 -10
- data/lib/coderay.rb +60 -62
- data/lib/coderay/duo.rb +55 -2
- data/lib/coderay/encoder.rb +39 -52
- data/lib/coderay/encoders/_map.rb +7 -11
- data/lib/coderay/encoders/comment_filter.rb +61 -0
- data/lib/coderay/encoders/count.rb +26 -11
- data/lib/coderay/encoders/debug.rb +60 -11
- data/lib/coderay/encoders/div.rb +8 -9
- data/lib/coderay/encoders/filter.rb +52 -12
- data/lib/coderay/encoders/html.rb +113 -106
- data/lib/coderay/encoders/html/css.rb +7 -2
- data/lib/coderay/encoders/html/numbering.rb +27 -24
- data/lib/coderay/encoders/html/output.rb +58 -15
- data/lib/coderay/encoders/json.rb +44 -37
- data/lib/coderay/encoders/lines_of_code.rb +56 -9
- data/lib/coderay/encoders/null.rb +13 -6
- data/lib/coderay/encoders/page.rb +8 -8
- data/lib/coderay/encoders/span.rb +9 -10
- data/lib/coderay/encoders/statistic.rb +114 -51
- data/lib/coderay/encoders/terminal.rb +10 -7
- data/lib/coderay/encoders/text.rb +36 -17
- data/lib/coderay/encoders/token_kind_filter.rb +58 -1
- data/lib/coderay/encoders/xml.rb +11 -13
- data/lib/coderay/encoders/yaml.rb +14 -16
- data/lib/coderay/for_redcloth.rb +1 -1
- data/lib/coderay/helpers/file_type.rb +240 -125
- data/lib/coderay/helpers/gzip_simple.rb +123 -0
- data/lib/coderay/helpers/plugin.rb +307 -241
- data/lib/coderay/helpers/word_list.rb +126 -65
- data/lib/coderay/scanner.rb +103 -153
- data/lib/coderay/scanners/_map.rb +16 -18
- data/lib/coderay/scanners/c.rb +13 -13
- data/lib/coderay/scanners/cpp.rb +6 -6
- data/lib/coderay/scanners/css.rb +48 -47
- data/lib/coderay/scanners/debug.rb +55 -9
- data/lib/coderay/scanners/delphi.rb +4 -4
- data/lib/coderay/scanners/diff.rb +25 -43
- data/lib/coderay/scanners/groovy.rb +2 -2
- data/lib/coderay/scanners/html.rb +30 -107
- data/lib/coderay/scanners/java.rb +5 -6
- data/lib/coderay/scanners/java/builtin_types.rb +0 -2
- data/lib/coderay/scanners/java_script.rb +6 -6
- data/lib/coderay/scanners/json.rb +6 -7
- data/lib/coderay/scanners/nitro_xhtml.rb +136 -0
- data/lib/coderay/scanners/php.rb +12 -13
- data/lib/coderay/scanners/plaintext.rb +26 -0
- data/lib/coderay/scanners/python.rb +4 -4
- data/lib/coderay/scanners/{erb.rb → rhtml.rb} +11 -19
- data/lib/coderay/scanners/ruby.rb +208 -219
- data/lib/coderay/scanners/ruby/patterns.rb +85 -18
- data/lib/coderay/scanners/scheme.rb +136 -0
- data/lib/coderay/scanners/sql.rb +22 -29
- data/lib/coderay/scanners/yaml.rb +10 -11
- data/lib/coderay/styles/_map.rb +2 -2
- data/lib/coderay/styles/alpha.rb +104 -102
- data/lib/coderay/styles/cycnus.rb +143 -0
- data/lib/coderay/styles/murphy.rb +123 -0
- data/lib/coderay/token_kinds.rb +86 -87
- data/lib/coderay/tokens.rb +169 -26
- data/test/functional/basic.rb +14 -200
- data/test/functional/examples.rb +14 -20
- data/test/functional/for_redcloth.rb +8 -15
- data/test/functional/load_plugin_scanner.rb +11 -0
- data/test/functional/suite.rb +6 -9
- data/test/functional/vhdl.rb +126 -0
- data/test/functional/word_list.rb +79 -0
- metadata +129 -107
- data/lib/coderay/helpers/gzip.rb +0 -41
- data/lib/coderay/scanners/clojure.rb +0 -217
- data/lib/coderay/scanners/haml.rb +0 -168
- data/lib/coderay/scanners/ruby/string_state.rb +0 -71
- data/lib/coderay/scanners/text.rb +0 -26
- data/lib/coderay/tokens_proxy.rb +0 -55
- data/lib/coderay/version.rb +0 -3
@@ -1,26 +0,0 @@
|
|
1
|
-
module CodeRay
|
2
|
-
module Scanners
|
3
|
-
|
4
|
-
# Scanner for plain text.
|
5
|
-
#
|
6
|
-
# Yields just one token of the kind :plain.
|
7
|
-
#
|
8
|
-
# Alias: +plaintext+, +plain+
|
9
|
-
class Text < Scanner
|
10
|
-
|
11
|
-
register_for :text
|
12
|
-
title 'Plain text'
|
13
|
-
|
14
|
-
KINDS_NOT_LOC = [:plain] # :nodoc:
|
15
|
-
|
16
|
-
protected
|
17
|
-
|
18
|
-
def scan_tokens encoder, options
|
19
|
-
encoder.text_token string, :plain
|
20
|
-
encoder
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
data/lib/coderay/tokens_proxy.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
module CodeRay
|
2
|
-
|
3
|
-
# The result of a scan operation is a TokensProxy, but should act like Tokens.
|
4
|
-
#
|
5
|
-
# This proxy makes it possible to use the classic CodeRay.scan.encode API
|
6
|
-
# while still providing the benefits of direct streaming.
|
7
|
-
class TokensProxy
|
8
|
-
|
9
|
-
attr_accessor :input, :lang, :options, :block
|
10
|
-
|
11
|
-
# Create a new TokensProxy with the arguments of CodeRay.scan.
|
12
|
-
def initialize input, lang, options = {}, block = nil
|
13
|
-
@input = input
|
14
|
-
@lang = lang
|
15
|
-
@options = options
|
16
|
-
@block = block
|
17
|
-
end
|
18
|
-
|
19
|
-
# Call CodeRay.encode if +encoder+ is a Symbol;
|
20
|
-
# otherwise, convert the receiver to tokens and call encoder.encode_tokens.
|
21
|
-
def encode encoder, options = {}
|
22
|
-
if encoder.respond_to? :to_sym
|
23
|
-
CodeRay.encode(input, lang, encoder, options)
|
24
|
-
else
|
25
|
-
encoder.encode_tokens tokens, options
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# Tries to call encode;
|
30
|
-
# delegates to tokens otherwise.
|
31
|
-
def method_missing method, *args, &blk
|
32
|
-
encode method.to_sym, *args
|
33
|
-
rescue PluginHost::PluginNotFound
|
34
|
-
tokens.send(method, *args, &blk)
|
35
|
-
end
|
36
|
-
|
37
|
-
# The (cached) result of the tokenized input; a Tokens instance.
|
38
|
-
def tokens
|
39
|
-
@tokens ||= scanner.tokenize(input)
|
40
|
-
end
|
41
|
-
|
42
|
-
# A (cached) scanner instance to use for the scan task.
|
43
|
-
def scanner
|
44
|
-
@scanner ||= CodeRay.scanner(lang, options, &block)
|
45
|
-
end
|
46
|
-
|
47
|
-
# Overwrite Struct#each.
|
48
|
-
def each *args, &blk
|
49
|
-
tokens.each(*args, &blk)
|
50
|
-
self
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
data/lib/coderay/version.rb
DELETED