Skip to content

Commit 5a833b2

Browse files
committed
always load the plugin map
1 parent 2de5dab commit 5a833b2

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

lib/coderay/helpers/plugin.rb

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def register plugin, id
131131

132132
# A Hash of plugion_id => Plugin pairs.
133133
def plugin_hash
134-
@plugin_hash ||= make_plugin_hash
134+
@plugin_hash ||= (@plugin_hash = make_plugin_hash).tap { load_plugin_map }
135135
end
136136

137137
# Returns an array of all .rb files in the plugin path.
@@ -158,7 +158,6 @@ def all_plugins
158158
# This is done automatically when plugin_path is called.
159159
def load_plugin_map
160160
mapfile = path_to '_map'
161-
@plugin_map_loaded = true
162161
if File.exist? mapfile
163162
require mapfile
164163
true
@@ -171,22 +170,16 @@ def load_plugin_map
171170

172171
# Return a plugin hash that automatically loads plugins.
173172
def make_plugin_hash
174-
@plugin_map_loaded ||= false
175173
Hash.new do |h, plugin_id|
176174
id = validate_id(plugin_id)
177175
path = path_to id
178176
begin
179177
require path
180178
rescue LoadError => boom
181-
if @plugin_map_loaded
182-
if h.has_key?(:default)
183-
h[:default]
184-
else
185-
raise PluginNotFound, '%p could not load plugin %p: %s' % [self, id, boom]
186-
end
179+
if h.has_key?(:default)
180+
h[:default]
187181
else
188-
load_plugin_map
189-
h[plugin_id]
182+
raise PluginNotFound, '%p could not load plugin %p: %s' % [self, id, boom]
190183
end
191184
else
192185
# Plugin should have registered by now
@@ -270,7 +263,6 @@ def plugin_host host = nil
270263
end
271264

272265
def aliases
273-
plugin_host.load_plugin_map
274266
plugin_host.plugin_hash.inject [] do |aliases, (key, _)|
275267
aliases << key if plugin_host[key] == self
276268
aliases

0 commit comments

Comments
 (0)