coderay 1.0.0.598.pre → 1.0.0.738.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/coderay +1 -1
- data/lib/coderay.rb +38 -32
- data/lib/coderay/duo.rb +1 -54
- data/lib/coderay/encoder.rb +31 -33
- data/lib/coderay/encoders/_map.rb +4 -2
- data/lib/coderay/encoders/comment_filter.rb +0 -61
- data/lib/coderay/encoders/count.rb +2 -23
- data/lib/coderay/encoders/debug.rb +11 -60
- data/lib/coderay/encoders/filter.rb +0 -46
- data/lib/coderay/encoders/html.rb +83 -91
- data/lib/coderay/encoders/html/css.rb +1 -6
- data/lib/coderay/encoders/html/numbering.rb +18 -21
- data/lib/coderay/encoders/html/output.rb +10 -52
- data/lib/coderay/encoders/json.rb +19 -39
- data/lib/coderay/encoders/lines_of_code.rb +7 -52
- data/lib/coderay/encoders/null.rb +6 -13
- data/lib/coderay/encoders/statistic.rb +30 -93
- data/lib/coderay/encoders/terminal.rb +3 -4
- data/lib/coderay/encoders/text.rb +1 -23
- data/lib/coderay/encoders/token_kind_filter.rb +0 -58
- data/lib/coderay/helpers/file_type.rb +119 -240
- data/lib/coderay/helpers/gzip.rb +41 -0
- data/lib/coderay/helpers/plugin.rb +237 -307
- data/lib/coderay/scanner.rb +112 -88
- data/lib/coderay/scanners/_map.rb +3 -3
- data/lib/coderay/scanners/c.rb +7 -7
- data/lib/coderay/scanners/clojure.rb +204 -0
- data/lib/coderay/scanners/css.rb +10 -20
- data/lib/coderay/scanners/debug.rb +9 -55
- data/lib/coderay/scanners/diff.rb +21 -4
- data/lib/coderay/scanners/html.rb +65 -18
- data/lib/coderay/scanners/java.rb +3 -2
- data/lib/coderay/scanners/java_script.rb +3 -3
- data/lib/coderay/scanners/json.rb +7 -6
- data/lib/coderay/scanners/php.rb +2 -1
- data/lib/coderay/scanners/rhtml.rb +6 -2
- data/lib/coderay/scanners/ruby.rb +193 -193
- data/lib/coderay/scanners/ruby/patterns.rb +15 -82
- data/lib/coderay/scanners/ruby/string_state.rb +71 -0
- data/lib/coderay/scanners/sql.rb +1 -1
- data/lib/coderay/scanners/yaml.rb +4 -2
- data/lib/coderay/styles/_map.rb +2 -2
- data/lib/coderay/styles/alpha.rb +48 -38
- data/lib/coderay/styles/cycnus.rb +2 -1
- data/lib/coderay/token_kinds.rb +88 -86
- data/lib/coderay/tokens.rb +88 -112
- data/test/functional/basic.rb +184 -5
- data/test/functional/examples.rb +4 -4
- data/test/functional/for_redcloth.rb +3 -2
- data/test/functional/suite.rb +7 -6
- metadata +11 -24
- data/lib/coderay/helpers/gzip_simple.rb +0 -123
- data/test/functional/load_plugin_scanner.rb +0 -11
- data/test/functional/vhdl.rb +0 -126
- 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,350 +1,280 @@
|
|
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
|
-
#
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
#
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
-
#
|
70
|
-
|
71
|
-
|
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
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
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
|
-
|
75
|
+
|
86
76
|
end
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
@plugin_path
|
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
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
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
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
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
|
+
plugin_hash[nil] = id
|
118
|
+
else
|
119
|
+
load nil
|
120
|
+
end
|
124
121
|
end
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
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]
|
122
|
+
|
123
|
+
# Every plugin must register itself for one or more
|
124
|
+
# +ids+ by calling register_for, which calls this method.
|
125
|
+
#
|
126
|
+
# See Plugin#register_for.
|
127
|
+
def register plugin, *ids
|
128
|
+
for id in ids
|
129
|
+
plugin_hash[validate_id(id)] = plugin
|
130
|
+
end
|
142
131
|
end
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
132
|
+
|
133
|
+
# A Hash of plugion_id => Plugin pairs.
|
134
|
+
def plugin_hash
|
135
|
+
@plugin_hash ||= make_plugin_hash
|
136
|
+
end
|
137
|
+
|
138
|
+
# Returns an array of all .rb files in the plugin path.
|
139
|
+
#
|
140
|
+
# The extension .rb is not included.
|
141
|
+
def list
|
142
|
+
Dir[path_to('*')].select do |file|
|
143
|
+
File.basename(file)[/^(?!_)\w+\.rb$/]
|
144
|
+
end.map do |file|
|
145
|
+
File.basename(file, '.rb').to_sym
|
154
146
|
end
|
155
|
-
plugin_hash[validate_id(id)] = plugin
|
156
147
|
end
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
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'
|
148
|
+
|
149
|
+
# Returns an array of all Plugins.
|
150
|
+
#
|
151
|
+
# Note: This loads all plugins using load_all.
|
152
|
+
def all_plugins
|
153
|
+
load_all
|
154
|
+
plugin_hash.values.grep(Class)
|
172
155
|
end
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
map[id] = plugin.to_s[/(?>\w+)$/]
|
156
|
+
|
157
|
+
# Returns an array of all plugin titles.
|
158
|
+
#
|
159
|
+
# Note: This loads all plugins using load_all.
|
160
|
+
def all_titles
|
161
|
+
all_plugins.map { |plugin| plugin.title }
|
180
162
|
end
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
@plugin_hash =
|
163
|
+
|
164
|
+
protected
|
165
|
+
|
166
|
+
# Return a plugin hash that automatically loads plugins.
|
167
|
+
def make_plugin_hash
|
168
|
+
map_loaded = false
|
188
169
|
Hash.new do |h, plugin_id|
|
189
170
|
id = validate_id(plugin_id)
|
190
171
|
path = path_to id
|
191
172
|
begin
|
173
|
+
raise LoadError, "#{path} not found" unless File.exist? path
|
192
174
|
require path
|
193
175
|
rescue LoadError => boom
|
194
|
-
if
|
195
|
-
h
|
176
|
+
if map_loaded
|
177
|
+
if h.has_key?(nil) # default plugin
|
178
|
+
h[nil]
|
179
|
+
else
|
180
|
+
raise PluginNotFound, 'Could not load plugin %p: %s' % [id, boom]
|
181
|
+
end
|
196
182
|
else
|
197
|
-
|
183
|
+
load_map
|
184
|
+
map_loaded = true
|
185
|
+
h[plugin_id]
|
198
186
|
end
|
199
187
|
else
|
200
188
|
# Plugin should have registered by now
|
201
|
-
|
202
|
-
|
203
|
-
|
189
|
+
if h.has_key? id
|
190
|
+
h[id]
|
191
|
+
else
|
192
|
+
raise PluginNotFound, "No #{self.name} plugin for #{id.inspect} found in #{path}."
|
204
193
|
end
|
205
194
|
end
|
206
|
-
h[id]
|
207
195
|
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
196
|
end
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
197
|
+
|
198
|
+
# Loads the map file (see map).
|
199
|
+
#
|
200
|
+
# This is done automatically when plugin_path is called.
|
201
|
+
def load_map
|
202
|
+
mapfile = path_to '_map'
|
203
|
+
require mapfile if File.exist? mapfile
|
204
|
+
end
|
205
|
+
|
206
|
+
# Returns the expected path to the plugin file for the given id.
|
207
|
+
def path_to plugin_id
|
208
|
+
File.join plugin_path, "#{plugin_id}.rb"
|
209
|
+
end
|
210
|
+
|
211
|
+
# Converts +id+ to a Symbol if it is a String,
|
212
|
+
# or returns +id+ if it already is a Symbol.
|
213
|
+
#
|
214
|
+
# Raises +ArgumentError+ for all other objects, or if the
|
215
|
+
# given String includes non-alphanumeric characters (\W).
|
216
|
+
def validate_id id
|
217
|
+
if id.is_a? Symbol or id.nil?
|
218
|
+
id
|
219
|
+
elsif id.is_a? String
|
220
|
+
if id[/\w+/] == id
|
221
|
+
id.downcase.to_sym
|
222
|
+
else
|
223
|
+
raise ArgumentError, "Invalid id given: #{id}"
|
224
|
+
end
|
247
225
|
else
|
248
|
-
raise ArgumentError, "
|
226
|
+
raise ArgumentError, "String or Symbol expected, but #{id.class} given."
|
249
227
|
end
|
250
|
-
else
|
251
|
-
raise ArgumentError,
|
252
|
-
"String or Symbol expected, but #{id.class} given."
|
253
228
|
end
|
254
|
-
|
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_id = ids.first
|
282
|
-
plugin_host.register self, *ids
|
229
|
+
|
283
230
|
end
|
284
231
|
|
285
|
-
|
286
|
-
#
|
287
|
-
def title title = nil
|
288
|
-
if title
|
289
|
-
@title = title.to_s
|
290
|
-
else
|
291
|
-
@title ||= name[/([^:]+)$/, 1]
|
292
|
-
end
|
293
|
-
end
|
294
|
-
|
295
|
-
# The host for this Plugin class.
|
296
|
-
def plugin_host host = nil
|
297
|
-
if host and not host.is_a? PluginHost
|
298
|
-
raise ArgumentError,
|
299
|
-
"PluginHost expected, but #{host.class} given."
|
300
|
-
end
|
301
|
-
self.const_set :PLUGIN_HOST, host if host
|
302
|
-
self::PLUGIN_HOST
|
303
|
-
end
|
304
|
-
|
305
|
-
# Require some helper files.
|
232
|
+
|
233
|
+
# = Plugin
|
306
234
|
#
|
307
|
-
#
|
235
|
+
# Plugins have to include this module.
|
308
236
|
#
|
309
|
-
#
|
310
|
-
# register_for :my_id
|
311
|
-
# helper :my_helper
|
237
|
+
# IMPORTANT: Use extend for this module.
|
312
238
|
#
|
313
|
-
#
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
239
|
+
# See CodeRay::PluginHost for examples.
|
240
|
+
module Plugin
|
241
|
+
|
242
|
+
# Register this class for the given langs.
|
243
|
+
# Example:
|
244
|
+
# class MyPlugin < PluginHost::BaseClass
|
245
|
+
# register_for :my_id
|
246
|
+
# ...
|
247
|
+
# end
|
248
|
+
#
|
249
|
+
# See PluginHost.register.
|
250
|
+
def register_for *ids
|
251
|
+
@plugin_id = ids.first
|
252
|
+
plugin_host.register self, *ids
|
253
|
+
end
|
254
|
+
|
255
|
+
# Returns the title of the plugin, or sets it to the
|
256
|
+
# optional argument +title+.
|
257
|
+
def title title = nil
|
258
|
+
if title
|
259
|
+
@title = title.to_s
|
323
260
|
else
|
324
|
-
|
261
|
+
@title ||= name[/([^:]+)$/, 1]
|
325
262
|
end
|
326
263
|
end
|
264
|
+
|
265
|
+
# The PluginHost for this Plugin class.
|
266
|
+
def plugin_host host = nil
|
267
|
+
if host.is_a? PluginHost
|
268
|
+
const_set :PLUGIN_HOST, host
|
269
|
+
end
|
270
|
+
self::PLUGIN_HOST
|
271
|
+
end
|
272
|
+
|
273
|
+
# Returns the plugin id used by the engine.
|
274
|
+
def plugin_id
|
275
|
+
@plugin_id ||= name[/\w+$/].downcase
|
276
|
+
end
|
277
|
+
|
327
278
|
end
|
328
|
-
|
329
|
-
# Returns the pulgin id used by the engine.
|
330
|
-
def plugin_id
|
331
|
-
@plugin_id || name[/\w+$/].downcase
|
332
|
-
end
|
333
|
-
|
334
|
-
end
|
335
|
-
|
336
|
-
# Convenience method for plugin loading.
|
337
|
-
# The syntax used is:
|
338
|
-
#
|
339
|
-
# CodeRay.require_plugin '<Host ID>/<Plugin ID>'
|
340
|
-
#
|
341
|
-
# Returns the loaded plugin.
|
342
|
-
def self.require_plugin path
|
343
|
-
host_id, plugin_id = path.split '/', 2
|
344
|
-
host = PluginHost.host_by_id(host_id)
|
345
|
-
raise PluginHost::HostNotFound,
|
346
|
-
"No host for #{host_id.inspect} found." unless host
|
347
|
-
host.load plugin_id
|
279
|
+
|
348
280
|
end
|
349
|
-
|
350
|
-
end
|