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.
Files changed (79) hide show
  1. data/FOLDERS +49 -0
  2. data/Rakefile +6 -5
  3. data/bin/coderay +74 -190
  4. data/bin/coderay_stylesheet +4 -0
  5. data/{README_INDEX.rdoc → lib/README} +20 -10
  6. data/lib/coderay.rb +60 -62
  7. data/lib/coderay/duo.rb +55 -2
  8. data/lib/coderay/encoder.rb +39 -52
  9. data/lib/coderay/encoders/_map.rb +7 -11
  10. data/lib/coderay/encoders/comment_filter.rb +61 -0
  11. data/lib/coderay/encoders/count.rb +26 -11
  12. data/lib/coderay/encoders/debug.rb +60 -11
  13. data/lib/coderay/encoders/div.rb +8 -9
  14. data/lib/coderay/encoders/filter.rb +52 -12
  15. data/lib/coderay/encoders/html.rb +113 -106
  16. data/lib/coderay/encoders/html/css.rb +7 -2
  17. data/lib/coderay/encoders/html/numbering.rb +27 -24
  18. data/lib/coderay/encoders/html/output.rb +58 -15
  19. data/lib/coderay/encoders/json.rb +44 -37
  20. data/lib/coderay/encoders/lines_of_code.rb +56 -9
  21. data/lib/coderay/encoders/null.rb +13 -6
  22. data/lib/coderay/encoders/page.rb +8 -8
  23. data/lib/coderay/encoders/span.rb +9 -10
  24. data/lib/coderay/encoders/statistic.rb +114 -51
  25. data/lib/coderay/encoders/terminal.rb +10 -7
  26. data/lib/coderay/encoders/text.rb +36 -17
  27. data/lib/coderay/encoders/token_kind_filter.rb +58 -1
  28. data/lib/coderay/encoders/xml.rb +11 -13
  29. data/lib/coderay/encoders/yaml.rb +14 -16
  30. data/lib/coderay/for_redcloth.rb +1 -1
  31. data/lib/coderay/helpers/file_type.rb +240 -125
  32. data/lib/coderay/helpers/gzip_simple.rb +123 -0
  33. data/lib/coderay/helpers/plugin.rb +307 -241
  34. data/lib/coderay/helpers/word_list.rb +126 -65
  35. data/lib/coderay/scanner.rb +103 -153
  36. data/lib/coderay/scanners/_map.rb +16 -18
  37. data/lib/coderay/scanners/c.rb +13 -13
  38. data/lib/coderay/scanners/cpp.rb +6 -6
  39. data/lib/coderay/scanners/css.rb +48 -47
  40. data/lib/coderay/scanners/debug.rb +55 -9
  41. data/lib/coderay/scanners/delphi.rb +4 -4
  42. data/lib/coderay/scanners/diff.rb +25 -43
  43. data/lib/coderay/scanners/groovy.rb +2 -2
  44. data/lib/coderay/scanners/html.rb +30 -107
  45. data/lib/coderay/scanners/java.rb +5 -6
  46. data/lib/coderay/scanners/java/builtin_types.rb +0 -2
  47. data/lib/coderay/scanners/java_script.rb +6 -6
  48. data/lib/coderay/scanners/json.rb +6 -7
  49. data/lib/coderay/scanners/nitro_xhtml.rb +136 -0
  50. data/lib/coderay/scanners/php.rb +12 -13
  51. data/lib/coderay/scanners/plaintext.rb +26 -0
  52. data/lib/coderay/scanners/python.rb +4 -4
  53. data/lib/coderay/scanners/{erb.rb → rhtml.rb} +11 -19
  54. data/lib/coderay/scanners/ruby.rb +208 -219
  55. data/lib/coderay/scanners/ruby/patterns.rb +85 -18
  56. data/lib/coderay/scanners/scheme.rb +136 -0
  57. data/lib/coderay/scanners/sql.rb +22 -29
  58. data/lib/coderay/scanners/yaml.rb +10 -11
  59. data/lib/coderay/styles/_map.rb +2 -2
  60. data/lib/coderay/styles/alpha.rb +104 -102
  61. data/lib/coderay/styles/cycnus.rb +143 -0
  62. data/lib/coderay/styles/murphy.rb +123 -0
  63. data/lib/coderay/token_kinds.rb +86 -87
  64. data/lib/coderay/tokens.rb +169 -26
  65. data/test/functional/basic.rb +14 -200
  66. data/test/functional/examples.rb +14 -20
  67. data/test/functional/for_redcloth.rb +8 -15
  68. data/test/functional/load_plugin_scanner.rb +11 -0
  69. data/test/functional/suite.rb +6 -9
  70. data/test/functional/vhdl.rb +126 -0
  71. data/test/functional/word_list.rb +79 -0
  72. metadata +129 -107
  73. data/lib/coderay/helpers/gzip.rb +0 -41
  74. data/lib/coderay/scanners/clojure.rb +0 -217
  75. data/lib/coderay/scanners/haml.rb +0 -168
  76. data/lib/coderay/scanners/ruby/string_state.rb +0 -71
  77. data/lib/coderay/scanners/text.rb +0 -26
  78. data/lib/coderay/tokens_proxy.rb +0 -55
  79. 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
@@ -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
@@ -1,3 +0,0 @@
1
- module CodeRay
2
- VERSION = '1.0.0'
3
- end