summaryrefslogtreecommitdiff
path: root/lib/ohai/loader.rb
diff options
context:
space:
mode:
authorClaire McQuin <claire@opscode.com>2013-09-02 20:29:28 -0700
committerClaire McQuin <claire@opscode.com>2013-09-02 20:29:28 -0700
commite6ce286a0d5049bb69a097813f4a15cc8bbbd52f (patch)
tree9de6ed5200ae21187d416415153bb50f4d1c439d /lib/ohai/loader.rb
parent5f2e9256a97163857112be6ac5fc2da7fed8b078 (diff)
downloadohai-e6ce286a0d5049bb69a097813f4a15cc8bbbd52f.tar.gz
add has_run? to plugin dsl, store plugin instance(s) with attributes
Diffstat (limited to 'lib/ohai/loader.rb')
-rw-r--r--lib/ohai/loader.rb19
1 files changed, 7 insertions, 12 deletions
diff --git a/lib/ohai/loader.rb b/lib/ohai/loader.rb
index 67f844d1..8cab2442 100644
--- a/lib/ohai/loader.rb
+++ b/lib/ohai/loader.rb
@@ -19,17 +19,16 @@
require 'ohai/log'
require 'ohai/mash'
require 'ohai/dsl/plugin'
-require 'ohai/mixin/from_file'
module Ohai
class Loader
- include Ohai::Mixin::FromFile
def initialize(controller)
+ @controller = controller
@attributes = controller.attributes
end
- def load_plugin(plugin_path, plugin_name=nil)
+ def load_plugin(plugin_path)
plugin = nil
contents = ""
@@ -42,7 +41,8 @@ module Ohai
if contents.include?("Ohai.plugin")
begin
- plugin = self.instance_eval(contents, plugin_path, 1)
+ klass = self.instance_eval(contents, plugin_path, 1)
+ plugin = klass.new(@controller, plugin_path) unless klass.nil?
rescue SystemExit, Interrupt
raise
rescue NoMethodError => e
@@ -55,20 +55,15 @@ module Ohai
collect_provides(plugin)
else
Ohai::Log.warn("[DEPRECATION] Plugin at #{plugin_path} is a version 6 plugin. Version 6 plugins will not be supported in future releases of Ohai. Please upgrage your plugin to version 7 plugin syntax. For more information visit here: XXX")
- plugin = Ohai.v6plugin do collect_contents contents end
- if plugin.nil?
- Ohai::Log.warn("Unable to load plugin at #{plugin_path}")
- return plugin
- end
+ klass = Ohai.v6plugin { collect_contents(contents) }
+ plugin = klass.new(@controller, plugin_path)
end
plugin
end
- private
-
def collect_provides(plugin)
- plugin_provides = plugin.provides_attrs
+ plugin_provides = plugin.class.provides_attrs
plugin_provides.each do |attr|
parts = attr.split('/')