Class: Ohai::DSL::Plugin::VersionVII

Inherits:
Ohai::DSL::Plugin show all
Defined in:
lib/ohai/dsl/plugin/versionvii.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(data) ⇒ VersionVII


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

def initialize(data)
  super(data)
  @source = self.class.sources
  @version = :version7
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/versionvii.rb', line 25

def source
  @source
end

#versionObject (readonly)

Returns the value of attribute version


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

def version
  @version
end

Class Method Details

.collect_data(platform = :default, *other_platforms, &block) ⇒ Object


69
70
71
72
73
74
75
76
77
# File 'lib/ohai/dsl/plugin/versionvii.rb', line 69

def self.collect_data(platform = :default, *other_platforms, &block)
  [platform, other_platforms].flatten.each do |plat|
    if data_collector.has_key?(plat)
      raise Ohai::Exceptions::IllegalPluginDefinition, "collect_data already defined on platform #{plat}"
    else
      data_collector[plat] = block
    end
  end
end

.data_collectorObject


53
54
55
# File 'lib/ohai/dsl/plugin/versionvii.rb', line 53

def self.data_collector
  @data_collector ||= Mash.new
end

.depends(*attrs) ⇒ Object


63
64
65
66
67
# File 'lib/ohai/dsl/plugin/versionvii.rb', line 63

def self.depends(*attrs)
  attrs.each do |attr|
    depends_attrs << attr unless depends_attrs.include?(attr)
  end
end

.depends_attrsObject


49
50
51
# File 'lib/ohai/dsl/plugin/versionvii.rb', line 49

def self.depends_attrs
  @depends_attrs ||= []
end

.provides(*attrs) ⇒ Object


57
58
59
60
61
# File 'lib/ohai/dsl/plugin/versionvii.rb', line 57

def self.provides(*attrs)
  attrs.each do |attr|
    provides_attrs << attr unless provides_attrs.include?(attr)
  end
end

.provides_attrsObject


45
46
47
# File 'lib/ohai/dsl/plugin/versionvii.rb', line 45

def self.provides_attrs
  @provides_attrs ||= []
end

.sourcesObject


41
42
43
# File 'lib/ohai/dsl/plugin/versionvii.rb', line 41

def self.sources
  @source_list ||= []
end

.versionObject


37
38
39
# File 'lib/ohai/dsl/plugin/versionvii.rb', line 37

def self.version
  :version7
end

Instance Method Details

#dependenciesObject


79
80
81
# File 'lib/ohai/dsl/plugin/versionvii.rb', line 79

def dependencies
  self.class.depends_attrs
end

#nameObject


33
34
35
# File 'lib/ohai/dsl/plugin/versionvii.rb', line 33

def name
  self.class.name.split("Ohai::NamedPlugin::")[1].to_sym
end

#provides(*paths) ⇒ Object


96
97
98
# File 'lib/ohai/dsl/plugin/versionvii.rb', line 96

def provides(*paths)
  Ohai::Log.warn("[UNSUPPORTED OPERATION] \'provides\' is no longer supported in a \'collect_data\' context. Please specify \'provides\' before collecting plugin data. Ignoring command \'provides #{paths.join(", ")}")
end

#require_plugin(*args) ⇒ Object


100
101
102
# File 'lib/ohai/dsl/plugin/versionvii.rb', line 100

def require_plugin(*args)
  Ohai::Log.warn("[UNSUPPORTED OPERATION] \'require_plugin\' is no longer supported. Please use \'depends\' instead.\nIgnoring plugin(s) #{args.join(", ")}")
end

#run_pluginObject


83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/ohai/dsl/plugin/versionvii.rb', line 83

def run_plugin
  collector = self.class.data_collector
  platform = collect_os

  if collector.has_key?(platform)
    self.instance_eval(&collector[platform])
  elsif collector.has_key?(:default)
    self.instance_eval(&collector[:default])
  else
    Ohai::Log.debug("No data to collect for plugin #{self.name}. Continuing...")
  end
end