# File bundler/plugin/index.rb, line 25 def initialize @plugin_paths = {} @commands = {} @sources = {} @hooks = {} @load_paths = {} begin load_index(global_index_file, true) rescue GenericSystemCallError # no need to fail when on a read-only FS, for example nil end load_index(local_index_file) if SharedHelpers.in_bundle? end
Fetch the name of plugin handling the command
# File bundler/plugin/index.rb, line 95 def command_plugin(command) @commands[command] end
Path where the global index file is stored
# File bundler/plugin/index.rb, line 77 def global_index_file Plugin.global_root.join("index") end
Returns the list of plugin names handling the passed event
# File bundler/plugin/index.rb, line 112 def hook_plugins(event) @hooks[event] || [] end
Path of default index file
# File bundler/plugin/index.rb, line 72 def index_file Plugin.root.join("index") end
# File bundler/plugin/index.rb, line 99 def installed?(name) @plugin_paths[name] end
# File bundler/plugin/index.rb, line 90 def load_paths(name) @load_paths[name] end
Path where the local index file is stored
# File bundler/plugin/index.rb, line 82 def local_index_file Plugin.local_root.join("index") end
# File bundler/plugin/index.rb, line 86 def plugin_path(name) Pathname.new @plugin_paths[name] end
This function is to be called when a new plugin is installed. This function shall add the functions of the plugin to existing maps and also the name to source location.
@param [String] name of the plugin to be registered @param [String] path where the plugin is installed @param [Array<String>] load_paths
for the plugin @param [Array<String>] commands that are handled by the plugin @param [Array<String>] sources that are handled by the plugin
# File bundler/plugin/index.rb, line 50 def register_plugin(name, path, load_paths, commands, sources, hooks) old_commands = @commands.dup common = commands & @commands.keys raise CommandConflict.new(name, common) unless common.empty? commands.each {|c| @commands[c] = name } common = sources & @sources.keys raise SourceConflict.new(name, common) unless common.empty? sources.each {|k| @sources[k] = name } hooks.each {|e| (@hooks[e] ||= []) << name } @plugin_paths[name] = path @load_paths[name] = load_paths save_index rescue StandardError @commands = old_commands raise end