Class: Ohai::DSL::Plugin::VersionVI

Inherits:
Ohai::DSL::Plugin show all
Defined in:
lib/ohai/dsl/plugin/versionvi.rb

Instance Attribute Summary collapse

Attributes inherited from Ohai::DSL::Plugin

#data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Ohai::DSL::Plugin

#[], #[]=, #each, #from, #from_with_regex, #get_attribute, #has_key?, #has_run?, #hint?, #method_missing, #reset!, #run, #safe_run, #set, #set_attribute

Methods included from Mixin::SecondsToHuman

#seconds_to_human

Methods included from Mixin::Command

popen4, run_command, #run_command_unix, #run_command_windows, shell_out

Methods included from Mixin::OS

collect_os

Constructor Details

#initialize(controller, plugin_path, plugin_dir_path) ⇒ VersionVI


27
28
29
30
31
32
33
# File 'lib/ohai/dsl/plugin/versionvi.rb', line 27

def initialize(controller, plugin_path, plugin_dir_path)
  super(controller.data)
  @controller = controller
  @version = :version6
  @source = plugin_path
  @plugin_dir_path = plugin_dir_path
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Ohai::DSL::Plugin

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source


25
26
27
# File 'lib/ohai/dsl/plugin/versionvi.rb', line 25

def source
  @source
end

#versionObject (readonly)

Returns the value of attribute version


24
25
26
# File 'lib/ohai/dsl/plugin/versionvi.rb', line 24

def version
  @version
end

Class Method Details

.collect_contents(contents) ⇒ Object


46
47
48
# File 'lib/ohai/dsl/plugin/versionvi.rb', line 46

def self.collect_contents(contents)
  define_method(:run_plugin) { self.instance_eval(contents) }
end

.versionObject


42
43
44
# File 'lib/ohai/dsl/plugin/versionvi.rb', line 42

def self.version
  :version6
end

Instance Method Details

#nameObject


35
36
37
38
39
40
# File 'lib/ohai/dsl/plugin/versionvi.rb', line 35

def name
  # Ohai V6 doesn't have any name specification for plugins. 
  # So we are using the partial path to infer the name of the plugin
  partial_path = Pathname.new(@source).relative_path_from(Pathname.new(@plugin_dir_path)).to_s
  partial_path.chomp(".rb").gsub("/", "::")
end

#provides(*paths) ⇒ Object


50
51
52
# File 'lib/ohai/dsl/plugin/versionvi.rb', line 50

def provides(*paths)
  Ohai::Log.debug("Skipping provides '#{paths.join(",")}' for plugin '#{name}'")
end

#require_plugin(plugin_ref) ⇒ Object


54
55
56
# File 'lib/ohai/dsl/plugin/versionvi.rb', line 54

def require_plugin(plugin_ref)
  @controller.require_plugin(plugin_ref)
end