diff options
author | Claire McQuin <claire@opscode.com> | 2013-10-15 11:45:24 -0700 |
---|---|---|
committer | Claire McQuin <claire@opscode.com> | 2013-10-17 12:07:31 -0700 |
commit | 2531afecc141c8a19ba8e8b2958cb275bb647fa5 (patch) | |
tree | c7edad3dfd036aa1680068f8f6bbd262d9bc029a | |
parent | b6b9d220869bd5c01be2e1a247e324222bb7a1ca (diff) | |
download | ohai-2531afecc141c8a19ba8e8b2958cb275bb647fa5.tar.gz |
actually make os a mixin and update corresponding files
-rw-r--r-- | lib/ohai/dsl/plugin.rb | 2 | ||||
-rw-r--r-- | lib/ohai/mixin/os.rb | 62 | ||||
-rw-r--r-- | lib/ohai/runner.rb | 2 | ||||
-rw-r--r-- | lib/ohai/system.rb | 2 |
4 files changed, 35 insertions, 33 deletions
diff --git a/lib/ohai/dsl/plugin.rb b/lib/ohai/dsl/plugin.rb index f3bb42cb..34178986 100644 --- a/lib/ohai/dsl/plugin.rb +++ b/lib/ohai/dsl/plugin.rb @@ -99,7 +99,7 @@ module Ohai module DSL class Plugin - include Ohai::OS + include Ohai::Mixin::OS include Ohai::Mixin::Command include Ohai::Mixin::SecondsToHuman diff --git a/lib/ohai/mixin/os.rb b/lib/ohai/mixin/os.rb index e9e8c27f..d42b1943 100644 --- a/lib/ohai/mixin/os.rb +++ b/lib/ohai/mixin/os.rb @@ -20,38 +20,40 @@ require 'rbconfig' module Ohai - module OS + module Mixin + module OS - def collect_os - case ::RbConfig::CONFIG['host_os'] - when /aix(.+)$/ - return "aix" - when /darwin(.+)$/ - return "darwin" - when /hpux(.+)$/ - return "hpux" - when /linux/ - return "linux" - when /freebsd(.+)$/ - return "freebsd" - when /openbsd(.+)$/ - return "openbsd" - when /netbsd(.*)$/ - return "netbsd" - when /solaris2/ - return "solaris2" - when /mswin|mingw32|windows/ - # After long discussion in IRC the "powers that be" have come to a consensus - # that no Windows platform exists that was not based on the - # Windows_NT kernel, so we herby decree that "windows" will refer to all - # platforms built upon the Windows_NT kernel and have access to win32 or win64 - # subsystems. - return "windows" - else - return ::RbConfig::CONFIG['host_os'] + def collect_os + case ::RbConfig::CONFIG['host_os'] + when /aix(.+)$/ + return "aix" + when /darwin(.+)$/ + return "darwin" + when /hpux(.+)$/ + return "hpux" + when /linux/ + return "linux" + when /freebsd(.+)$/ + return "freebsd" + when /openbsd(.+)$/ + return "openbsd" + when /netbsd(.*)$/ + return "netbsd" + when /solaris2/ + return "solaris2" + when /mswin|mingw32|windows/ + # After long discussion in IRC the "powers that be" have come to a consensus + # that no Windows platform exists that was not based on the + # Windows_NT kernel, so we herby decree that "windows" will refer to all + # platforms built upon the Windows_NT kernel and have access to win32 or win64 + # subsystems. + return "windows" + else + return ::RbConfig::CONFIG['host_os'] + end end - end - module_function :collect_os + module_function :collect_os + end end end diff --git a/lib/ohai/runner.rb b/lib/ohai/runner.rb index e2f5ed18..15334e75 100644 --- a/lib/ohai/runner.rb +++ b/lib/ohai/runner.rb @@ -66,7 +66,7 @@ module Ohai attrs = @attributes parts = attribute.split('/') parts.each do |part| - next if part == Ohai::OS.collect_os + next if part == Ohai::Mixin::OS.collect_os raise NoAttributeError, "Cannot find plugin providing attribute \'#{attribute}\'" unless attrs[part] attrs = attrs[part] end diff --git a/lib/ohai/system.rb b/lib/ohai/system.rb index 50a1611d..37d7a87d 100644 --- a/lib/ohai/system.rb +++ b/lib/ohai/system.rb @@ -55,7 +55,7 @@ module Ohai Ohai::Config[:plugin_path].each do |path| [ Dir[File.join(path, '*')], - Dir[File.join(path, Ohai::OS.collect_os, '**', '*')] + Dir[File.join(path, Ohai::Mixin::OS.collect_os, '**', '*')] ].flatten.each do |file| file_regex = Regexp.new("#{File.expand_path(path)}#{File::SEPARATOR}(.+).rb$") md = file_regex.match(file) |