class PuppetLint::Plugins
Public: Various methods that implement puppet-lint's plugin system
Examples
PuppetLint::Plugins.load_spec_helper
Public Class Methods
load_from_gems()
click to toggle source
Internal: Find any gems containing puppet-lint plugins and load them.
Returns nothing.
# File lib/puppet-lint/plugins.rb, line 13 def self.load_from_gems gem_directories.select { |path| (path + 'puppet-lint/plugins').directory? }.each do |gem_path| Dir["#{gem_path + 'puppet-lint/plugins'}/*.rb"].each do |file| load(file) end end end
load_spec_helper()
click to toggle source
Public: Load the puppet-lint spec_helper.rb
Returns nothings.
# File lib/puppet-lint/plugins.rb, line 26 def self.load_spec_helper gemspec = gemspecs.select { |spec| spec.name == 'puppet-lint' }.first load(Pathname.new(gemspec.full_gem_path) + 'spec/spec_helper.rb') end
Private Class Methods
gem_directories()
click to toggle source
Internal: Retrieve a list of available gem paths from RubyGems.
Returns an Array of Pathname objects.
# File lib/puppet-lint/plugins.rb, line 67 def gem_directories if rubygems? gemspecs.reject { |spec| spec.name == 'puppet-lint' }.map do |spec| Pathname.new(spec.full_gem_path) + 'lib' end else [] end end
gemspecs()
click to toggle source
Internal: Retrieve a list of avaliable gemspecs.
Returns an Array of Gem::Specification objects.
# File lib/puppet-lint/plugins.rb, line 44 def gemspecs @gemspecs ||= if Gem::Specification.respond_to?(:latest_specs) Gem::Specification.latest_specs(load_prerelease_plugins?) else Gem.searcher.init_gemspecs end end
load_prerelease_plugins?()
click to toggle source
Internal: Determine whether to load plugins that contain a letter in their version number.
Returns true if the configuration is set to load “prerelease” gems, false otherwise.
# File lib/puppet-lint/plugins.rb, line 55 def load_prerelease_plugins? # Load prerelease plugins (which ruby defines as any gem which has a letter in its version number). # Can't use puppet-lint configuration object here because this code executes before the command line is parsed. if ENV['PUPPET_LINT_LOAD_PRERELEASE_PLUGINS'] return %w[true yes].include?(ENV['PUPPET_LINT_LOAD_PRERELEASE_PLUGINS'].downcase) end false end
rubygems?()
click to toggle source
Internal: Check if RubyGems is loaded and available.
Returns true if RubyGems is available, false if not.
# File lib/puppet-lint/plugins.rb, line 37 def rubygems? defined?(::Gem) end