class Pluginator::Autodetect::Finder
Find plugins
Attributes
gem_plugins_paths[R]
load_path_plugins_paths[R]
loaded_plugins_path[R]
Public Class Methods
new(force_prefix, group, force_type)
click to toggle source
Automatically load plugins for given group (and type)
@param force_prefix [String] a prefix for finding plugins if forcing,
by default only `/lib` is checked, regexp notation is allowed, for example `/[lib|]`
@param group [String] name of the plugins group @param force_type [String] name of the plugin type if forcing
# File lib/pluginator/autodetect/finder.rb, line 35 def initialize(force_prefix, group, force_type) @force_prefix = force_prefix @group = group @force_type = force_type @pattern = file_name_pattern find_paths end
Private Instance Methods
file_name_pattern()
click to toggle source
group => pattern
# File lib/pluginator/autodetect/finder.rb, line 46 def file_name_pattern "plugins/#{@group}/#{@force_type || "**"}/*.rb" end
find_gem_plugins()
click to toggle source
# File lib/pluginator/autodetect/finder.rb, line 68 def find_gem_plugins split_file_names( Gem.find_files(@pattern, false) ) end
find_load_path_plugins()
click to toggle source
# File lib/pluginator/autodetect/finder.rb, line 62 def find_load_path_plugins split_file_names( Gem.find_files_from_load_path(@pattern) ) end
find_loaded_plugins()
click to toggle source
# File lib/pluginator/autodetect/finder.rb, line 56 def find_loaded_plugins split_file_names( $LOADED_FEATURES ).compact end
find_paths()
click to toggle source
# File lib/pluginator/autodetect/finder.rb, line 50 def find_paths @loaded_plugins_path = find_loaded_plugins @load_path_plugins_paths = find_load_path_plugins - @loaded_plugins_path @gem_plugins_paths = find_gem_plugins - @load_path_plugins_paths - @loaded_plugins_path end
split_file_name(file_name)
click to toggle source
file_name => [ path, full_name, type ]
# File lib/pluginator/autodetect/finder.rb, line 81 def split_file_name(file_name) prefix = @force_prefix || "/lib" type = @force_type || ".*" match = file_name.match(%r{.*#{prefix}/(plugins/(#{@group}/(#{type})/[^/]*)\.rb)$}) match[-3..-1] if match end
split_file_names(file_names)
click to toggle source
# File lib/pluginator/autodetect/finder.rb, line 74 def split_file_names(file_names) file_names.map do |file_name| split_file_name(file_name) end end