module Retrospec::PluginLoader
Public Class Methods
gem_directories()
click to toggle source
Internal: Retrieve a list of available gem paths from RubyGems. filter out the main retrospec gem, then filter out any plugin that is not a retrospec gem.
Returns an Array of Pathname objects.
# File lib/retrospec/plugin_loader.rb, line 21 def self.gem_directories dirs = [] if has_rubygems? dirs = gemspecs.reject { |spec| spec.name == 'retrospec' }.map do |spec| lib_path = File.expand_path(File.join(spec.full_gem_path,'lib')) lib_path if File.exists? File.join(lib_path,'retrospec','plugins') end end dirs.reject { |dir| dir.nil? } end
gemspecs()
click to toggle source
Internal: Retrieve a list of available gemspecs.
Returns an Array of Gem::Specification objects.
# File lib/retrospec/plugin_loader.rb, line 48 def self.gemspecs @gemspecs ||= if Gem::Specification.respond_to?(:latest_specs) Gem::Specification.latest_specs else Gem.searcher.init_gemspecs end end
has_rubygems?()
click to toggle source
Internal: Check if RubyGems is loaded and available.
Returns true if RubyGems is available, false if not.
# File lib/retrospec/plugin_loader.rb, line 41 def self.has_rubygems? defined? ::Gem end
load_from_gems(version='v1')
click to toggle source
Internal: Find any gems containing retrospec plugins and load the main file in them.
Returns nothing.
# File lib/retrospec/plugin_loader.rb, line 8 def self.load_from_gems(version='v1') gem_directories.each do |gem_path| Dir[File.join(gem_path,'*.rb')].each do |file| load file end end end
retrospec_gem_list()
click to toggle source
returns a list of retrospec gem plugin specs
# File lib/retrospec/plugin_loader.rb, line 34 def self.retrospec_gem_list gemspecs.reject { |spec| spec.name == 'retrospec' or ! File.directory?(File.join(spec.full_gem_path,'lib','retrospec','plugins')) } end