In Files

  • bundler/plugin/index.rb

Class/Module Index [+]

Quicksearch

Bundler::Plugin::Index

Attributes

commands[R]

Public Class Methods

new() click to toggle source
 
               # 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
            

Public Instance Methods

command_plugin(command) click to toggle source

Fetch the name of plugin handling the command

 
               # File bundler/plugin/index.rb, line 107
def command_plugin(command)
  @commands[command]
end
            
global_index_file() click to toggle source

Path where the global index file is stored

 
               # File bundler/plugin/index.rb, line 89
def global_index_file
  Plugin.global_root.join("index")
end
            
hook_plugins(event) click to toggle source

Returns the list of plugin names handling the passed event

 
               # File bundler/plugin/index.rb, line 132
def hook_plugins(event)
  @hooks[event] || []
end
            
index_file() click to toggle source

Path of default index file

 
               # File bundler/plugin/index.rb, line 84
def index_file
  Plugin.root.join("index")
end
            
installed?(name) click to toggle source
 
               # File bundler/plugin/index.rb, line 111
def installed?(name)
  @plugin_paths[name]
end
            
installed_plugins() click to toggle source
 
               # File bundler/plugin/index.rb, line 115
def installed_plugins
  @plugin_paths.keys
end
            
load_paths(name) click to toggle source
 
               # File bundler/plugin/index.rb, line 102
def load_paths(name)
  @load_paths[name]
end
            
local_index_file() click to toggle source

Path where the local index file is stored

 
               # File bundler/plugin/index.rb, line 94
def local_index_file
  Plugin.local_root.join("index")
end
            
plugin_commands(plugin) click to toggle source
 
               # File bundler/plugin/index.rb, line 119
def plugin_commands(plugin)
  @commands.find_all {|_, n| n == plugin }.map(&:first)
end
            
plugin_path(name) click to toggle source
 
               # File bundler/plugin/index.rb, line 98
def plugin_path(name)
  Pathname.new @plugin_paths[name]
end
            
register_plugin(name, path, load_paths, commands, sources, hooks) click to toggle source

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 do |event|
    event_hooks = (@hooks[event] ||= []) << name
    event_hooks.uniq!
  end

  @plugin_paths[name] = path
  @load_paths[name] = load_paths
  save_index
rescue StandardError
  @commands = old_commands
  raise
end
            
source?(source) click to toggle source
 
               # File bundler/plugin/index.rb, line 123
def source?(source)
  @sources.key? source
end
            
source_plugin(name) click to toggle source
 
               # File bundler/plugin/index.rb, line 127
def source_plugin(name)
  @sources[name]
end
            
unregister_plugin(name) click to toggle source
 
               # File bundler/plugin/index.rb, line 74
def unregister_plugin(name)
  @commands.delete_if {|_, v| v == name }
  @sources.delete_if {|_, v| v == name }
  @hooks.each {|_, plugin_names| plugin_names.delete(name) }
  @plugin_paths.delete(name)
  @load_paths.delete(name)
  save_index
end