Class Index [+]

Quicksearch

LittlePlugger::ClassMethods

Public Instance Methods

disregard_plugin( *names ) click to toggle source

Add the names to the list of plugins that will not be loaded. This list prevents the plugin system from loading unwanted or unneeded plugins.

If a plugin name appears in both the ‘disregard_plugin’ list and the ‘plugin’ list, the disregard list takes precedence; that is, the plugin will not be loaded.

     # File lib/little-plugger.rb, line 137
137:     def disregard_plugin( *names )
138:       @disregard_plugin ||= []
139:       @disregard_plugin.concat(names.map! {|n| n.to_sym})
140:       @disregard_plugin
141:     end
Also aliased as: disregard_plugins
disregard_plugins( *names ) click to toggle source
Alias for: disregard_plugin
initialize_plugins() click to toggle source

Iterate over the loaded plugin classes and modules and call the initialize method for each plugin. The plugin’s initialize method is defeind as initialize_plugin_name, where the plugin name is unique to each plugin.

     # File lib/little-plugger.rb, line 175
175:     def initialize_plugins
176:       plugins.each do |name, klass|
177:         msg = "initialize_#{name}"
178:         klass.send msg if klass.respond_to? msg
179:       end
180:     end
load_plugins() click to toggle source

Iterate through all installed gems looking for those that have the plugin_path in their “lib” folder, and load all .rb files found in the gem’s plugin path. Each .rb file should define one class or module that will be used as a plugin.

     # File lib/little-plugger.rb, line 187
187:     def load_plugins
188:       @loaded ||= {}
189:       found = {}
190: 
191:       Gem.find_files(File.join(plugin_path, '*.rb')).each do |path|
192:         name = File.basename(path, '.rb').to_sym
193:         found[name] = path unless found.key? name
194:       end
195: 
196:       :keep_on_truckin while found.map { |name, path|
197:         next unless plugin_names.empty? or plugin_names.include? name
198:         next if disregard_plugins.include? name
199:         next if @loaded[name]
200:         begin
201:           @loaded[name] = load path
202:         rescue ScriptError, StandardError => err
203:           warn "Error loading #{path.inspect}: #{err.message}. skipping..."
204:         end
205:       }.any?
206:     end
plugin( *names ) click to toggle source

Add the names to the list of plugins that will be loaded.

     # File lib/little-plugger.rb, line 125
125:     def plugin( *names )
126:       plugin_names.concat(names.map! {|n| n.to_sym})
127:     end
plugin_module() click to toggle source

This module or class where plugins are located.

     # File lib/little-plugger.rb, line 216
216:     def plugin_module
217:       ::LittlePlugger.default_plugin_module(plugin_path)
218:     end
plugin_names() click to toggle source

Returns the array of plugin names that will be loaded. If the array is empty, then any plugin found in the plugin_path will be loaded.

     # File lib/little-plugger.rb, line 147
147:     def plugin_names
148:       @plugin_names ||= []
149:     end
plugin_path() click to toggle source

The path to search in a gem’s ‘lib’ folder for plugins.

     # File lib/little-plugger.rb, line 210
210:     def plugin_path
211:       ::LittlePlugger.default_plugin_path(self)
212:     end
plugins() click to toggle source

Loads the desired plugins and returns a hash. The hash contains all the plugin classes and modules keyed by the plugin name.

     # File lib/little-plugger.rb, line 154
154:     def plugins
155:       load_plugins
156:       pm = plugin_module
157:       names = pm.constants.map { |s| s.to_s }
158:       names.reject! { |n| n =~ /^[A-Z_]+$/ }
159: 
160:       h = {}
161:       names.each do |name|
162:         sym = ::LittlePlugger.underscore(name).to_sym
163:         next unless plugin_names.empty? or plugin_names.include? sym
164:         next if disregard_plugins.include? sym
165:         h[sym] = pm.const_get name
166:       end
167:       h
168:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.