Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hi! I cleaned up your code for you! #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Release Notes - Ohai - Version 0.3.2
http://tickets.opscode.com

** Bug
* [OHAI-93] - plugin linux::kernel threw exception #<Errno::ENOENT: No such file or directory - /sbin/lsmod>
* [OHAI-93] - plugin linux::kernel threw exception #<Errno::ENOENT: No such file or directory - /sbin/lsmod>
* [OHAI-99] - Network media hash on darwin is nigh-unsable
* [OHAI-100] - hostname output differs between redhat dirivatives and debian dirivatives distributions
* [OHAI-102] - no uptime data for darwin/osx
Expand Down
4 changes: 2 additions & 2 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Contributors and Copyright holders:
* Copyright 2008-2009, Ezra Zygmuntowicz <[email protected]>
* Copyright 2009, Joe Williams <[email protected]>
* Copyright 2009, Paul Nasrat <[email protected]>

Parts of Ohai were taken from Chef, a configuration management system.

Ohai incorporates functionality from Open4 (http://www.codeforpeople.com/lib/ruby/open4/).
Expand All @@ -29,4 +29,4 @@ Contributors and Copyright holders:
* Copyright 2008, Arjuna Christensen <[email protected]>
* Copyright 2008, Bryan McLellan <[email protected]>
* Copyright 2008, Ezra Zygmuntowicz <[email protected]>

4 changes: 2 additions & 2 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Install the following RubyGems.

* rake
* rspec
* extlib
* extlib
* systemu
* json

Expand All @@ -50,7 +50,7 @@ Ohai has some Rake tasks for doing various things.
rake package # Build all the packages
rake repackage # Force a rebuild of the package files
rake spec # Run specs

($VERSION is the current version, from the GemSpec in Rakefile)

== Spec Testing:
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ spec = Gem::Specification.new do |s|
s.author = AUTHOR
s.email = EMAIL
s.homepage = HOMEPAGE

s.add_dependency "json"
s.add_dependency "extlib"
s.add_dependency "systemu"
s.bindir = "bin"
s.executables = %w(ohai)

s.require_path = 'lib'
s.autorequire = GEM
s.files = %w(LICENSE README.rdoc Rakefile) + Dir.glob("{extras,lib,spec}/**/*")
Expand Down
7 changes: 3 additions & 4 deletions features/ohai.feature.pending
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
Feature: Collects data about a system
In order to understand the state of my system
In order to understand the state of my system
As a Systems Administrator
I want to have a program that detects information for me

Scenario: Collect data about the system via a single plugin
Given a plugin called 'platform'
When I run ohai
Then I should have a 'platform' of 'kitties'

Scenario: Collect data about the system via a directory of plugins
Given a plugin directory at './plugins'
When I run ohai
Then I should have a 'platform' of 'kitties'
And I should have a 'foghorn' of 'leghorn'

Scenario: Collect data about the system via an external script
Given a plugin called 'perl'
When I run ohai
Then I should have a 'perl_major_version' of '5'

4 changes: 2 additions & 2 deletions features/steps/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def setup_active_project_folder project_name
FileUtils.chdir(@active_project_folder) do
if Object.const_defined?("APP_ROOT")
APP_ROOT.replace(FileUtils.pwd)
else
else
APP_ROOT = FileUtils.pwd
end
run_generator(generator, arguments.split(' '), SOURCES)
Expand Down Expand Up @@ -117,7 +117,7 @@ def setup_active_project_folder project_name
actual_output = File.read(@stdout)
(does == 'does') ?
actual_output.should(match(/#{regex}/)) :
actual_output.should_not(match(/#{regex}/))
actual_output.should_not(match(/#{regex}/))
end

Then %r{^contents of file '(.*)' (does|does not) match \/(.*)\/} do |file, does, regex|
Expand Down
4 changes: 2 additions & 2 deletions lib/ohai.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down
18 changes: 9 additions & 9 deletions lib/ohai/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -33,18 +33,18 @@ class Config
:log_location => STDOUT,
:plugin_path => [ File.expand_path(File.join(File.dirname(__FILE__), 'plugins')) ]
}

class << self
include Ohai::Mixin::FromFile

# Pass Ohai::Config.configure() a block, and it will yield @configuration.
#
# === Parameters
# <block>:: A block that takes @configure as its argument
def configure(&block)
yield @configuration
end

# Get the value of a configuration option
#
# === Parameters
Expand All @@ -62,7 +62,7 @@ def [](config_option)
raise ArgumentError, "Cannot find configuration option #{config_option.to_s}"
end
end

# Set the value of a configuration option
#
# === Parameters
Expand All @@ -74,7 +74,7 @@ def [](config_option)
def []=(config_option, value)
@configuration[config_option.to_sym] = value
end

# Check if Ohai::Config has a configuration option.
#
# === Parameters
Expand All @@ -86,7 +86,7 @@ def []=(config_option, value)
def has_key?(key)
@configuration.has_key?(key.to_sym)
end

# Allows for simple lookups and setting of configuration options via method calls
# on Ohai::Config. If there any arguments to the method, they are used to set
# the value of the configuration option. Otherwise, it's a simple get operation.
Expand All @@ -112,7 +112,7 @@ def method_missing(method_symbol, *args)
raise ArgumentError, "Cannot find configuration option #{method_symbol.to_s}"
end
end

end # class << self
end
end
4 changes: 2 additions & 2 deletions lib/ohai/exception.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down
18 changes: 9 additions & 9 deletions lib/ohai/log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -22,12 +22,12 @@

module Ohai
class Log

@logger = nil

class << self
attr_accessor :logger #:nodoc

# Use Ohai::Logger.init when you want to set up the logger manually. Arguments to this method
# get passed directly to Logger.new, so check out the documentation for the standard Logger class
# to understand what to do here.
Expand All @@ -44,7 +44,7 @@ def init(*opts)
@logger.formatter = Ohai::Log::Formatter.new()
level(Ohai::Config.log_level)
end

# Sets the level for the Logger object by symbol. Valid arguments are:
#
# :debug
Expand All @@ -71,9 +71,9 @@ def level(loglevel)
raise ArgumentError, "Log level must be one of :debug, :info, :warn, :error, or :fatal"
end
end

# Passes any other method calls on directly to the underlying Logger object created with init. If
# this method gets hit before a call to Ohai::Logger.init has been made, it will call
# this method gets hit before a call to Ohai::Logger.init has been made, it will call
# Ohai::Logger.init() with no arguments.
def method_missing(method_symbol, *args)
init() unless @logger
Expand All @@ -83,7 +83,7 @@ def method_missing(method_symbol, *args)
@logger.send(method_symbol)
end
end

end # class << self
end
end
12 changes: 6 additions & 6 deletions lib/ohai/log/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -23,11 +23,11 @@ module Ohai
class Log
class Formatter < Logger::Formatter
@@show_time = true

def self.show_time=(show=false)
@@show_time = show
end

# Prints a log message as '[time] severity: message' if Ohai::Log::Formatter.show_time == true.
# Otherwise, doesn't print the time.
def call(severity, time, progname, msg)
Expand All @@ -37,9 +37,9 @@ def call(severity, time, progname, msg)
sprintf("%s: %s\n", severity, msg2str(msg))
end
end

# Converts some argument to a Logger.severity() call to a string. Regular strings pass through like
# normal, Exceptions get formatted as "message (class)\nbacktrace", and other random stuff gets
# normal, Exceptions get formatted as "message (class)\nbacktrace", and other random stuff gets
# put through "object.inspect"
def msg2str(msg)
case msg
Expand Down
Loading