summaryrefslogtreecommitdiff
path: root/lib/bundler/plugin/index.rb
diff options
context:
space:
mode:
authorAsutosh Palai <asupalai@gmail.com>2016-05-21 12:02:01 +0530
committerAsutosh Palai <asupalai@gmail.com>2016-05-24 21:15:01 +0530
commit00098cda3d4b73f3c74199434c889f20e05b0485 (patch)
treeda0d5376a341a2f789bc8cc9e0647cb44951eff9 /lib/bundler/plugin/index.rb
parentf16146033bdc586d37630a671a49fc13374e2780 (diff)
downloadbundler-00098cda3d4b73f3c74199434c889f20e05b0485.tar.gz
Added documentations to the functions
Diffstat (limited to 'lib/bundler/plugin/index.rb')
-rw-r--r--lib/bundler/plugin/index.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/bundler/plugin/index.rb b/lib/bundler/plugin/index.rb
index d548475064..4f0a57ee05 100644
--- a/lib/bundler/plugin/index.rb
+++ b/lib/bundler/plugin/index.rb
@@ -2,6 +2,9 @@
require "yaml"
module Bundler
+ # Manages which plugins are installed and their sources. This also is supposed to map
+ # which plugin does what (currently the features are not implemented so this class is
+ # now just a stub class).
class Plugin::Index
def initialize
@@ -10,6 +13,7 @@ module Bundler
load_index
end
+ # Reads the index file from the directory and initializes the instance variables.
def load_index
SharedHelpers.filesystem_access(index_file, :read) do |index_f|
valid_file = index_f && index_f.exist? && !index_f.size.zero?
@@ -19,6 +23,8 @@ module Bundler
end
end
+ # Should be called when any of the instance variables change. Stores the instance
+ # variables in YAML format. (The instance variables are supposed to be just String key value pairs)
def save_index
index = {
:plugin_sources => @plugin_sources
@@ -30,12 +36,18 @@ module Bundler
end
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
def register_plugin(name, path)
@plugin_sources[name] = path
save_index
end
+ # Path where the index file is stored
def index_file
Plugin.root.join("index")
end