coderay 0.9.8 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. data/{lib/README → README_INDEX.rdoc} +10 -21
  2. data/Rakefile +6 -6
  3. data/bin/coderay +193 -64
  4. data/lib/coderay.rb +61 -105
  5. data/lib/coderay/duo.rb +17 -21
  6. data/lib/coderay/encoder.rb +100 -112
  7. data/lib/coderay/encoders/_map.rb +12 -7
  8. data/lib/coderay/encoders/comment_filter.rb +12 -30
  9. data/lib/coderay/encoders/count.rb +29 -11
  10. data/lib/coderay/encoders/debug.rb +32 -20
  11. data/lib/coderay/encoders/div.rb +13 -9
  12. data/lib/coderay/encoders/filter.rb +34 -51
  13. data/lib/coderay/encoders/html.rb +155 -161
  14. data/lib/coderay/encoders/html/css.rb +4 -9
  15. data/lib/coderay/encoders/html/numbering.rb +115 -0
  16. data/lib/coderay/encoders/html/output.rb +22 -70
  17. data/lib/coderay/encoders/json.rb +59 -45
  18. data/lib/coderay/encoders/lines_of_code.rb +12 -57
  19. data/lib/coderay/encoders/null.rb +6 -14
  20. data/lib/coderay/encoders/page.rb +13 -9
  21. data/lib/coderay/encoders/span.rb +13 -9
  22. data/lib/coderay/encoders/statistic.rb +58 -39
  23. data/lib/coderay/encoders/terminal.rb +179 -0
  24. data/lib/coderay/encoders/text.rb +31 -17
  25. data/lib/coderay/encoders/token_kind_filter.rb +111 -0
  26. data/lib/coderay/encoders/xml.rb +19 -18
  27. data/lib/coderay/encoders/yaml.rb +37 -9
  28. data/lib/coderay/for_redcloth.rb +4 -4
  29. data/lib/coderay/helpers/file_type.rb +127 -246
  30. data/lib/coderay/helpers/gzip.rb +41 -0
  31. data/lib/coderay/helpers/plugin.rb +241 -306
  32. data/lib/coderay/helpers/word_list.rb +65 -126
  33. data/lib/coderay/scanner.rb +173 -156
  34. data/lib/coderay/scanners/_map.rb +18 -17
  35. data/lib/coderay/scanners/c.rb +63 -77
  36. data/lib/coderay/scanners/clojure.rb +217 -0
  37. data/lib/coderay/scanners/cpp.rb +71 -84
  38. data/lib/coderay/scanners/css.rb +103 -120
  39. data/lib/coderay/scanners/debug.rb +47 -44
  40. data/lib/coderay/scanners/delphi.rb +70 -76
  41. data/lib/coderay/scanners/diff.rb +141 -50
  42. data/lib/coderay/scanners/erb.rb +81 -0
  43. data/lib/coderay/scanners/groovy.rb +104 -113
  44. data/lib/coderay/scanners/haml.rb +168 -0
  45. data/lib/coderay/scanners/html.rb +181 -110
  46. data/lib/coderay/scanners/java.rb +73 -75
  47. data/lib/coderay/scanners/java/builtin_types.rb +2 -0
  48. data/lib/coderay/scanners/java_script.rb +90 -101
  49. data/lib/coderay/scanners/json.rb +40 -53
  50. data/lib/coderay/scanners/php.rb +123 -147
  51. data/lib/coderay/scanners/python.rb +93 -91
  52. data/lib/coderay/scanners/raydebug.rb +66 -0
  53. data/lib/coderay/scanners/ruby.rb +343 -326
  54. data/lib/coderay/scanners/ruby/patterns.rb +40 -106
  55. data/lib/coderay/scanners/ruby/string_state.rb +71 -0
  56. data/lib/coderay/scanners/sql.rb +80 -66
  57. data/lib/coderay/scanners/text.rb +26 -0
  58. data/lib/coderay/scanners/xml.rb +1 -1
  59. data/lib/coderay/scanners/yaml.rb +74 -73
  60. data/lib/coderay/style.rb +10 -7
  61. data/lib/coderay/styles/_map.rb +3 -3
  62. data/lib/coderay/styles/alpha.rb +143 -0
  63. data/lib/coderay/token_kinds.rb +90 -0
  64. data/lib/coderay/tokens.rb +102 -277
  65. data/lib/coderay/tokens_proxy.rb +55 -0
  66. data/lib/coderay/version.rb +3 -0
  67. data/test/functional/basic.rb +200 -18
  68. data/test/functional/examples.rb +130 -0
  69. data/test/functional/for_redcloth.rb +15 -8
  70. data/test/functional/suite.rb +9 -6
  71. metadata +103 -123
  72. data/FOLDERS +0 -53
  73. data/bin/coderay_stylesheet +0 -4
  74. data/lib/coderay/encoders/html/numerization.rb +0 -133
  75. data/lib/coderay/encoders/term.rb +0 -158
  76. data/lib/coderay/encoders/token_class_filter.rb +0 -84
  77. data/lib/coderay/helpers/gzip_simple.rb +0 -123
  78. data/lib/coderay/scanners/nitro_xhtml.rb +0 -136
  79. data/lib/coderay/scanners/plaintext.rb +0 -20
  80. data/lib/coderay/scanners/rhtml.rb +0 -78
  81. data/lib/coderay/scanners/scheme.rb +0 -145
  82. data/lib/coderay/styles/cycnus.rb +0 -152
  83. data/lib/coderay/styles/murphy.rb +0 -134
  84. data/lib/coderay/token_classes.rb +0 -86
  85. data/test/functional/load_plugin_scanner.rb +0 -11
  86. data/test/functional/vhdl.rb +0 -126
  87. data/test/functional/word_list.rb +0 -79
@@ -0,0 +1,41 @@
1
+ module CodeRay
2
+
3
+ # A simplified interface to the gzip library +zlib+ (from the Ruby Standard Library.)
4
+ module GZip
5
+
6
+ require 'zlib'
7
+
8
+ # The default zipping level. 7 zips good and fast.
9
+ DEFAULT_GZIP_LEVEL = 7
10
+
11
+ # Unzips the given string +s+.
12
+ #
13
+ # Example:
14
+ # require 'gzip_simple'
15
+ # print GZip.gunzip(File.read('adresses.gz'))
16
+ def GZip.gunzip s
17
+ Zlib::Inflate.inflate s
18
+ end
19
+
20
+ # Zips the given string +s+.
21
+ #
22
+ # Example:
23
+ # require 'gzip_simple'
24
+ # File.open('adresses.gz', 'w') do |file
25
+ # file.write GZip.gzip('Mum: 0123 456 789', 9)
26
+ # end
27
+ #
28
+ # If you provide a +level+, you can control how strong
29
+ # the string is compressed:
30
+ # - 0: no compression, only convert to gzip format
31
+ # - 1: compress fast
32
+ # - 7: compress more, but still fast (default)
33
+ # - 8: compress more, slower
34
+ # - 9: compress best, very slow
35
+ def GZip.gzip s, level = DEFAULT_GZIP_LEVEL
36
+ Zlib::Deflate.new(level).deflate s, Zlib::FINISH
37
+ end
38
+
39
+ end
40
+
41
+ end
@@ -1,349 +1,284 @@
1
1
  module CodeRay
2
2
 
3
- # = PluginHost
4
- #
5
- # A simple subclass plugin system.
6
- #
7
- # Example:
8
- # class Generators < PluginHost
9
- # plugin_path 'app/generators'
10
- # end
11
- #
12
- # class Generator
13
- # extend Plugin
14
- # PLUGIN_HOST = Generators
15
- # end
16
- #
17
- # class FancyGenerator < Generator
18
- # register_for :fancy
19
- # end
20
- #
21
- # Generators[:fancy] #-> FancyGenerator
22
- # # or
23
- # CodeRay.require_plugin 'Generators/fancy'
24
- module PluginHost
25
-
26
- # Raised if Encoders::[] fails because:
27
- # * a file could not be found
28
- # * the requested Encoder is not registered
29
- PluginNotFound = Class.new Exception
30
- HostNotFound = Class.new Exception
31
-
32
- PLUGIN_HOSTS = []
33
- PLUGIN_HOSTS_BY_ID = {} # dummy hash
34
-
35
- # Loads all plugins using list and load.
36
- def load_all
37
- for plugin in list
38
- load plugin
39
- end
40
- end
41
-
42
- # Returns the Plugin for +id+.
3
+ # = PluginHost
4
+ #
5
+ # A simple subclass/subfolder plugin system.
43
6
  #
44
7
  # Example:
45
- # yaml_plugin = MyPluginHost[:yaml]
46
- def [] id, *args, &blk
47
- plugin = validate_id(id)
48
- begin
49
- plugin = plugin_hash.[] plugin, *args, &blk
50
- end while plugin.is_a? Symbol
51
- plugin
52
- end
53
-
54
- # Alias for +[]+.
55
- alias load []
56
-
57
- def require_helper plugin_id, helper_name
58
- path = path_to File.join(plugin_id, helper_name)
59
- require path
60
- end
61
-
62
- class << self
63
-
64
- # Adds the module/class to the PLUGIN_HOSTS list.
65
- def extended mod
66
- PLUGIN_HOSTS << mod
8
+ # class Generators
9
+ # extend PluginHost
10
+ # plugin_path 'app/generators'
11
+ # end
12
+ #
13
+ # class Generator
14
+ # extend Plugin
15
+ # PLUGIN_HOST = Generators
16
+ # end
17
+ #
18
+ # class FancyGenerator < Generator
19
+ # register_for :fancy
20
+ # end
21
+ #
22
+ # Generators[:fancy] #-> FancyGenerator
23
+ # # or
24
+ # CodeRay.require_plugin 'Generators/fancy'
25
+ # # or
26
+ # Generators::Fancy
27
+ module PluginHost
28
+
29
+ # Raised if Encoders::[] fails because:
30
+ # * a file could not be found
31
+ # * the requested Plugin is not registered
32
+ PluginNotFound = Class.new LoadError
33
+ HostNotFound = Class.new LoadError
34
+
35
+ PLUGIN_HOSTS = []
36
+ PLUGIN_HOSTS_BY_ID = {} # dummy hash
37
+
38
+ # Loads all plugins using list and load.
39
+ def load_all
40
+ for plugin in list
41
+ load plugin
42
+ end
67
43
  end
68
-
69
- # Warns you that you should not #include this module.
70
- def included mod
71
- warn "#{name} should not be included. Use extend."
44
+
45
+ # Returns the Plugin for +id+.
46
+ #
47
+ # Example:
48
+ # yaml_plugin = MyPluginHost[:yaml]
49
+ def [] id, *args, &blk
50
+ plugin = validate_id(id)
51
+ begin
52
+ plugin = plugin_hash.[] plugin, *args, &blk
53
+ end while plugin.is_a? Symbol
54
+ plugin
72
55
  end
73
-
74
- # Find the PluginHost for host_id.
75
- def host_by_id host_id
76
- unless PLUGIN_HOSTS_BY_ID.default_proc
77
- ph = Hash.new do |h, a_host_id|
78
- for host in PLUGIN_HOSTS
79
- h[host.host_id] = host
80
- end
81
- h.fetch a_host_id, nil
82
- end
83
- PLUGIN_HOSTS_BY_ID.replace ph
56
+
57
+ alias load []
58
+
59
+ # Tries to +load+ the missing plugin by translating +const+ to the
60
+ # underscore form (eg. LinesOfCode becomes lines_of_code).
61
+ def const_missing const
62
+ id = const.to_s.
63
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
64
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
65
+ downcase
66
+ load id
67
+ end
68
+
69
+ class << self
70
+
71
+ # Adds the module/class to the PLUGIN_HOSTS list.
72
+ def extended mod
73
+ PLUGIN_HOSTS << mod
84
74
  end
85
- PLUGIN_HOSTS_BY_ID[host_id]
75
+
86
76
  end
87
-
88
- end
89
-
90
- # The path where the plugins can be found.
91
- def plugin_path *args
92
- unless args.empty?
93
- @plugin_path = File.expand_path File.join(*args)
94
- load_map
77
+
78
+ # The path where the plugins can be found.
79
+ def plugin_path *args
80
+ unless args.empty?
81
+ @plugin_path = File.expand_path File.join(*args)
82
+ end
83
+ @plugin_path ||= ''
95
84
  end
96
- @plugin_path
97
- end
98
-
99
- # The host's ID.
100
- #
101
- # If PLUGIN_HOST_ID is not set, it is simply the class name.
102
- def host_id
103
- if self.const_defined? :PLUGIN_HOST_ID
104
- self::PLUGIN_HOST_ID
105
- else
106
- name
85
+
86
+ # Map a plugin_id to another.
87
+ #
88
+ # Usage: Put this in a file plugin_path/_map.rb.
89
+ #
90
+ # class MyColorHost < PluginHost
91
+ # map :navy => :dark_blue,
92
+ # :maroon => :brown,
93
+ # :luna => :moon
94
+ # end
95
+ def map hash
96
+ for from, to in hash
97
+ from = validate_id from
98
+ to = validate_id to
99
+ plugin_hash[from] = to unless plugin_hash.has_key? from
100
+ end
107
101
  end
108
- end
109
-
110
- # Map a plugin_id to another.
111
- #
112
- # Usage: Put this in a file plugin_path/_map.rb.
113
- #
114
- # class MyColorHost < PluginHost
115
- # map :navy => :dark_blue,
116
- # :maroon => :brown,
117
- # :luna => :moon
118
- # end
119
- def map hash
120
- for from, to in hash
121
- from = validate_id from
122
- to = validate_id to
123
- plugin_hash[from] = to unless plugin_hash.has_key? from
102
+
103
+ # Define the default plugin to use when no plugin is found
104
+ # for a given id, or return the default plugin.
105
+ #
106
+ # See also map.
107
+ #
108
+ # class MyColorHost < PluginHost
109
+ # map :navy => :dark_blue
110
+ # default :gray
111
+ # end
112
+ #
113
+ # MyColorHost.default # loads and returns the Gray plugin
114
+ def default id = nil
115
+ if id
116
+ id = validate_id id
117
+ raise "The default plugin can't be named \"default\"." if id == :default
118
+ plugin_hash[:default] = id
119
+ else
120
+ load :default
121
+ end
124
122
  end
125
- end
126
-
127
- # Define the default plugin to use when no plugin is found
128
- # for a given id.
129
- #
130
- # See also map.
131
- #
132
- # class MyColorHost < PluginHost
133
- # map :navy => :dark_blue
134
- # default :gray
135
- # end
136
- def default id = nil
137
- if id
138
- id = validate_id id
139
- plugin_hash[nil] = id
140
- else
141
- plugin_hash[nil]
123
+
124
+ # Every plugin must register itself for +id+ by calling register_for,
125
+ # which calls this method.
126
+ #
127
+ # See Plugin#register_for.
128
+ def register plugin, id
129
+ plugin_hash[validate_id(id)] = plugin
142
130
  end
143
- end
144
-
145
- # Every plugin must register itself for one or more
146
- # +ids+ by calling register_for, which calls this method.
147
- #
148
- # See Plugin#register_for.
149
- def register plugin, *ids
150
- for id in ids
151
- unless id.is_a? Symbol
152
- raise ArgumentError,
153
- "id must be a Symbol, but it was a #{id.class}"
131
+
132
+ # A Hash of plugion_id => Plugin pairs.
133
+ def plugin_hash
134
+ @plugin_hash ||= make_plugin_hash
135
+ end
136
+
137
+ # Returns an array of all .rb files in the plugin path.
138
+ #
139
+ # The extension .rb is not included.
140
+ def list
141
+ Dir[path_to('*')].select do |file|
142
+ File.basename(file)[/^(?!_)\w+\.rb$/]
143
+ end.map do |file|
144
+ File.basename(file, '.rb').to_sym
154
145
  end
155
- plugin_hash[validate_id(id)] = plugin
156
146
  end
157
- end
158
-
159
- # A Hash of plugion_id => Plugin pairs.
160
- def plugin_hash
161
- @plugin_hash ||= create_plugin_hash
162
- end
163
-
164
- # Returns an array of all .rb files in the plugin path.
165
- #
166
- # The extension .rb is not included.
167
- def list
168
- Dir[path_to('*')].select do |file|
169
- File.basename(file)[/^(?!_)\w+\.rb$/]
170
- end.map do |file|
171
- File.basename file, '.rb'
147
+
148
+ # Returns an array of all Plugins.
149
+ #
150
+ # Note: This loads all plugins using load_all.
151
+ def all_plugins
152
+ load_all
153
+ plugin_hash.values.grep(Class)
172
154
  end
173
- end
174
-
175
- # Makes a map of all loaded plugins.
176
- def inspect
177
- map = plugin_hash.dup
178
- map.each do |id, plugin|
179
- map[id] = plugin.to_s[/(?>\w+)$/]
155
+
156
+ # Loads the map file (see map).
157
+ #
158
+ # This is done automatically when plugin_path is called.
159
+ def load_plugin_map
160
+ mapfile = path_to '_map'
161
+ @plugin_map_loaded = true
162
+ if File.exist? mapfile
163
+ require mapfile
164
+ true
165
+ else
166
+ false
167
+ end
180
168
  end
181
- "#{name}[#{host_id}]#{map.inspect}"
182
- end
183
-
184
- protected
185
- # Created a new plugin list and stores it to @plugin_hash.
186
- def create_plugin_hash
187
- @plugin_hash =
169
+
170
+ protected
171
+
172
+ # Return a plugin hash that automatically loads plugins.
173
+ def make_plugin_hash
174
+ @plugin_map_loaded ||= false
188
175
  Hash.new do |h, plugin_id|
189
176
  id = validate_id(plugin_id)
190
177
  path = path_to id
191
178
  begin
179
+ raise LoadError, "#{path} not found" unless File.exist? path
192
180
  require path
193
181
  rescue LoadError => boom
194
- if h.has_key? nil # default plugin
195
- h[id] = h[nil]
182
+ if @plugin_map_loaded
183
+ if h.has_key?(:default)
184
+ warn '%p could not load plugin %p; falling back to %p' % [self, id, h[:default]]
185
+ h[:default]
186
+ else
187
+ raise PluginNotFound, '%p could not load plugin %p: %s' % [self, id, boom]
188
+ end
196
189
  else
197
- raise PluginNotFound, 'Could not load plugin %p: %s' % [id, boom]
190
+ load_plugin_map
191
+ h[plugin_id]
198
192
  end
199
193
  else
200
194
  # Plugin should have registered by now
201
- unless h.has_key? id
202
- raise PluginNotFound,
203
- "No #{self.name} plugin for #{id.inspect} found in #{path}."
195
+ if h.has_key? id
196
+ h[id]
197
+ else
198
+ raise PluginNotFound, "No #{self.name} plugin for #{id.inspect} found in #{path}."
204
199
  end
205
200
  end
206
- h[id]
207
201
  end
208
- end
209
-
210
- # Loads the map file (see map).
211
- #
212
- # This is done automatically when plugin_path is called.
213
- def load_map
214
- mapfile = path_to '_map'
215
- if File.exist? mapfile
216
- require mapfile
217
- elsif $VERBOSE
218
- warn 'no _map.rb found for %s' % name
219
202
  end
220
- end
221
-
222
- # Returns the Plugin for +id+.
223
- # Use it like Hash#fetch.
224
- #
225
- # Example:
226
- # yaml_plugin = MyPluginHost[:yaml, :default]
227
- def fetch id, *args, &blk
228
- plugin_hash.fetch validate_id(id), *args, &blk
229
- end
230
-
231
- # Returns the expected path to the plugin file for the given id.
232
- def path_to plugin_id
233
- File.join plugin_path, "#{plugin_id}.rb"
234
- end
235
-
236
- # Converts +id+ to a Symbol if it is a String,
237
- # or returns +id+ if it already is a Symbol.
238
- #
239
- # Raises +ArgumentError+ for all other objects, or if the
240
- # given String includes non-alphanumeric characters (\W).
241
- def validate_id id
242
- if id.is_a? Symbol or id.nil?
243
- id
244
- elsif id.is_a? String
245
- if id[/\w+/] == id
246
- id.downcase.to_sym
203
+
204
+ # Returns the expected path to the plugin file for the given id.
205
+ def path_to plugin_id
206
+ File.join plugin_path, "#{plugin_id}.rb"
207
+ end
208
+
209
+ # Converts +id+ to a Symbol if it is a String,
210
+ # or returns +id+ if it already is a Symbol.
211
+ #
212
+ # Raises +ArgumentError+ for all other objects, or if the
213
+ # given String includes non-alphanumeric characters (\W).
214
+ def validate_id id
215
+ if id.is_a? Symbol or id.nil?
216
+ id
217
+ elsif id.is_a? String
218
+ if id[/\w+/] == id
219
+ id.downcase.to_sym
220
+ else
221
+ raise ArgumentError, "Invalid id given: #{id}"
222
+ end
247
223
  else
248
- raise ArgumentError, "Invalid id: '#{id}' given."
224
+ raise ArgumentError, "String or Symbol expected, but #{id.class} given."
249
225
  end
250
- else
251
- raise ArgumentError,
252
- "String or Symbol expected, but #{id.class} given."
253
226
  end
254
- end
255
-
256
- end
257
-
258
-
259
- # = Plugin
260
- #
261
- # Plugins have to include this module.
262
- #
263
- # IMPORTANT: use extend for this module.
264
- #
265
- # Example: see PluginHost.
266
- module Plugin
267
-
268
- def included mod
269
- warn "#{name} should not be included. Use extend."
270
- end
271
-
272
- # Register this class for the given langs.
273
- # Example:
274
- # class MyPlugin < PluginHost::BaseClass
275
- # register_for :my_id
276
- # ...
277
- # end
278
- #
279
- # See PluginHost.register.
280
- def register_for *ids
281
- plugin_host.register self, *ids
227
+
282
228
  end
283
229
 
284
- # Returns the title of the plugin, or sets it to the
285
- # optional argument +title+.
286
- def title title = nil
287
- if title
288
- @title = title.to_s
289
- else
290
- @title ||= name[/([^:]+)$/, 1]
291
- end
292
- end
293
-
294
- # The host for this Plugin class.
295
- def plugin_host host = nil
296
- if host and not host.is_a? PluginHost
297
- raise ArgumentError,
298
- "PluginHost expected, but #{host.class} given."
299
- end
300
- self.const_set :PLUGIN_HOST, host if host
301
- self::PLUGIN_HOST
302
- end
303
-
304
- # Require some helper files.
230
+
231
+ # = Plugin
305
232
  #
306
- # Example:
233
+ # Plugins have to include this module.
307
234
  #
308
- # class MyPlugin < PluginHost::BaseClass
309
- # register_for :my_id
310
- # helper :my_helper
235
+ # IMPORTANT: Use extend for this module.
311
236
  #
312
- # The above example loads the file myplugin/my_helper.rb relative to the
313
- # file in which MyPlugin was defined.
314
- #
315
- # You can also load a helper from a different plugin:
316
- #
317
- # helper 'other_plugin/helper_name'
318
- def helper *helpers
319
- for helper in helpers
320
- if helper.is_a?(String) && helper[/\//]
321
- self::PLUGIN_HOST.require_helper $`, $'
237
+ # See CodeRay::PluginHost for examples.
238
+ module Plugin
239
+
240
+ attr_reader :plugin_id
241
+
242
+ # Register this class for the given +id+.
243
+ #
244
+ # Example:
245
+ # class MyPlugin < PluginHost::BaseClass
246
+ # register_for :my_id
247
+ # ...
248
+ # end
249
+ #
250
+ # See PluginHost.register.
251
+ def register_for id
252
+ @plugin_id = id
253
+ plugin_host.register self, id
254
+ end
255
+
256
+ # Returns the title of the plugin, or sets it to the
257
+ # optional argument +title+.
258
+ def title title = nil
259
+ if title
260
+ @title = title.to_s
322
261
  else
323
- self::PLUGIN_HOST.require_helper plugin_id, helper.to_s
262
+ @title ||= name[/([^:]+)$/, 1]
324
263
  end
325
264
  end
265
+
266
+ # The PluginHost for this Plugin class.
267
+ def plugin_host host = nil
268
+ if host.is_a? PluginHost
269
+ const_set :PLUGIN_HOST, host
270
+ end
271
+ self::PLUGIN_HOST
272
+ end
273
+
274
+ def aliases
275
+ plugin_host.load_plugin_map
276
+ plugin_host.plugin_hash.inject [] do |aliases, (key, _)|
277
+ aliases << key if plugin_host[key] == self
278
+ aliases
279
+ end
280
+ end
281
+
326
282
  end
327
-
328
- # Returns the pulgin id used by the engine.
329
- def plugin_id
330
- name[/\w+$/].downcase
331
- end
332
-
333
- end
334
-
335
- # Convenience method for plugin loading.
336
- # The syntax used is:
337
- #
338
- # CodeRay.require_plugin '<Host ID>/<Plugin ID>'
339
- #
340
- # Returns the loaded plugin.
341
- def self.require_plugin path
342
- host_id, plugin_id = path.split '/', 2
343
- host = PluginHost.host_by_id(host_id)
344
- raise PluginHost::HostNotFound,
345
- "No host for #{host_id.inspect} found." unless host
346
- host.load plugin_id
283
+
347
284
  end
348
-
349
- end