Sha256: e409a2e4fd0acacce4dd18120359abbfaf489a51f75b023a214caa35102ec2c6
Contents?: true
Size: 1.23 KB
Versions: 6
Compression:
Stored size: 1.23 KB
Contents
require 'ohai' require 'cupper/ohai_plugins' module Cupper class Collect ADDITIONAL_OHAI_PLUGINS = [ 'packages', 'platform_family', 'etc' ] def initialize @data_extraction = Hash.new('No data!') @ohai = Ohai::System.new @ohai_plugin = OhaiPlugin.new # TODO: Ohai::Config[:plugin_path] is decrepted @plugins_path = Cupper::OHAI_PLUGINS_PATH Ohai::Config[:plugin_path] << @plugins_path end def extract(attribute) begin object = 'Cupper::'.concat self.platform.capitalize platform = Object.const_get(object).new extract = platform.method attribute extract.call @data_extraction rescue NameError puts 'Not supported platform' # TODO: treat this better end end def setup plugins = @ohai_plugin.list plugins.concat ADDITIONAL_OHAI_PLUGINS plugins.each do |plugin| extract = @ohai.all_plugins(plugin) @data_extraction.update({ plugin => extract.first.data }) # Assuming that the first is the default plugin extractor end true end def platform @data_extraction['platform_family']['platform_family'] end def data @data_extraction end end end
Version data entries
6 entries across 6 versions & 1 rubygems