opscode-ohai 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/LICENSE +201 -0
  2. data/README.rdoc +56 -0
  3. data/Rakefile +58 -0
  4. data/bin/ohai +58 -0
  5. data/lib/ohai.rb +27 -0
  6. data/lib/ohai/config.rb +118 -0
  7. data/lib/ohai/exception.rb +23 -0
  8. data/lib/ohai/log.rb +89 -0
  9. data/lib/ohai/log/formatter.rb +57 -0
  10. data/lib/ohai/mixin/command.rb +198 -0
  11. data/lib/ohai/mixin/from_file.rb +36 -0
  12. data/lib/ohai/plugins/command.rb +19 -0
  13. data/lib/ohai/plugins/darwin/hostname.rb +20 -0
  14. data/lib/ohai/plugins/darwin/kernel.rb +31 -0
  15. data/lib/ohai/plugins/darwin/network.rb +154 -0
  16. data/lib/ohai/plugins/darwin/platform.rb +34 -0
  17. data/lib/ohai/plugins/darwin/ps.rb +21 -0
  18. data/lib/ohai/plugins/darwin/ssh_host_key.rb +24 -0
  19. data/lib/ohai/plugins/ec2.rb +41 -0
  20. data/lib/ohai/plugins/hostname.rb +23 -0
  21. data/lib/ohai/plugins/kernel.rb +24 -0
  22. data/lib/ohai/plugins/keys.rb +20 -0
  23. data/lib/ohai/plugins/languages.rb +19 -0
  24. data/lib/ohai/plugins/linux/block_device.rb +36 -0
  25. data/lib/ohai/plugins/linux/cpu.rb +58 -0
  26. data/lib/ohai/plugins/linux/filesystem.rb +55 -0
  27. data/lib/ohai/plugins/linux/hostname.rb +20 -0
  28. data/lib/ohai/plugins/linux/kernel.rb +31 -0
  29. data/lib/ohai/plugins/linux/lsb.rb +36 -0
  30. data/lib/ohai/plugins/linux/memory.rb +81 -0
  31. data/lib/ohai/plugins/linux/network.rb +103 -0
  32. data/lib/ohai/plugins/linux/platform.rb +41 -0
  33. data/lib/ohai/plugins/linux/ps.rb +21 -0
  34. data/lib/ohai/plugins/linux/ssh_host_key.rb +24 -0
  35. data/lib/ohai/plugins/linux/uptime.rb +26 -0
  36. data/lib/ohai/plugins/network.rb +48 -0
  37. data/lib/ohai/plugins/ohai_time.rb +19 -0
  38. data/lib/ohai/plugins/os.rb +34 -0
  39. data/lib/ohai/plugins/platform.rb +23 -0
  40. data/lib/ohai/plugins/ruby.rb +33 -0
  41. data/lib/ohai/plugins/uptime.rb +42 -0
  42. data/lib/ohai/system.rb +163 -0
  43. data/spec/ohai/log/log_formatter_spec.rb +50 -0
  44. data/spec/ohai/log_spec.rb +63 -0
  45. data/spec/ohai/mixin/from_file_spec.rb +53 -0
  46. data/spec/ohai/plugins/darwin/hostname_spec.rb +34 -0
  47. data/spec/ohai/plugins/darwin/kernel_spec.rb +35 -0
  48. data/spec/ohai/plugins/darwin/platform_spec.rb +67 -0
  49. data/spec/ohai/plugins/hostname_spec.rb +33 -0
  50. data/spec/ohai/plugins/kernel_spec.rb +41 -0
  51. data/spec/ohai/plugins/linux/cpu_spec.rb +128 -0
  52. data/spec/ohai/plugins/linux/hostname_spec.rb +34 -0
  53. data/spec/ohai/plugins/linux/kernel_spec.rb +31 -0
  54. data/spec/ohai/plugins/linux/lsb_spec.rb +59 -0
  55. data/spec/ohai/plugins/linux/platform_spec.rb +51 -0
  56. data/spec/ohai/plugins/linux/uptime_spec.rb +61 -0
  57. data/spec/ohai/plugins/ohai_time_spec.rb +46 -0
  58. data/spec/ohai/plugins/os_spec.rb +58 -0
  59. data/spec/ohai/plugins/platform_spec.rb +56 -0
  60. data/spec/ohai/plugins/ruby_spec.rb +49 -0
  61. data/spec/ohai/system_spec.rb +130 -0
  62. data/spec/ohai_spec.rb +27 -0
  63. data/spec/rcov.opts +2 -0
  64. data/spec/spec.opts +2 -0
  65. data/spec/spec_helper.rb +47 -0
  66. metadata +138 -0
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,56 @@
1
+ = ohai
2
+
3
+ * http://wiki.opscode.com/display/ohai
4
+
5
+ == DESCRIPTION:
6
+
7
+ Ohai detects data about your operating system.
8
+
9
+ I'm in yur server, findin yer dater
10
+
11
+ == SYNOPSIS:
12
+
13
+ ./bin/ohai
14
+
15
+ Will print out a JSON structure for all the known data about
16
+ your system.
17
+
18
+ == REQUIREMENTS:
19
+
20
+ * rake
21
+ * json
22
+ * rspec
23
+ * extlib
24
+
25
+ == INSTALL:
26
+
27
+ * git clone git@github.com:hjkp/ohai.git
28
+ * cd ohai
29
+ * rake install
30
+
31
+ == SPECIAL THANKS:
32
+
33
+ Ohai was significantly easier to build because of the pre-existing
34
+ work of everyone who contributed to Facter, especially Luke Kanies
35
+ of Reductive Labs. Thanks, guys. (We didn't use your code, but we
36
+ were strongly inspired by it.)
37
+
38
+ == LICENSE:
39
+
40
+ Ohai - system information application
41
+
42
+ Author:: Adam Jacob (<adam@opscode.com>)
43
+ Copyright:: Copyright (c) 2008 Opscode, Inc.
44
+ License:: Apache License, Version 2.0
45
+
46
+ Licensed under the Apache License, Version 2.0 (the "License");
47
+ you may not use this file except in compliance with the License.
48
+ You may obtain a copy of the License at
49
+
50
+ http://www.apache.org/licenses/LICENSE-2.0
51
+
52
+ Unless required by applicable law or agreed to in writing, software
53
+ distributed under the License is distributed on an "AS IS" BASIS,
54
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
55
+ See the License for the specific language governing permissions and
56
+ limitations under the License.
@@ -0,0 +1,58 @@
1
+ require 'rubygems'
2
+ require 'rake/gempackagetask'
3
+ require 'rubygems/specification'
4
+ require 'date'
5
+ require 'spec/rake/spectask'
6
+
7
+ GEM = "ohai"
8
+ GEM_VERSION = "0.1.2"
9
+ AUTHOR = "Adam Jacob"
10
+ EMAIL = "adam@opscode.com"
11
+ HOMEPAGE = "http://wiki.opscode.com/display/ohai"
12
+ SUMMARY = "Ohai profiles your system and emits JSON"
13
+
14
+ spec = Gem::Specification.new do |s|
15
+ s.name = GEM
16
+ s.version = GEM_VERSION
17
+ s.platform = Gem::Platform::RUBY
18
+ s.has_rdoc = true
19
+ s.summary = SUMMARY
20
+ s.description = s.summary
21
+ s.author = AUTHOR
22
+ s.email = EMAIL
23
+ s.homepage = HOMEPAGE
24
+
25
+ s.add_dependency "json"
26
+ s.add_dependency "extlib"
27
+ s.bindir = "bin"
28
+ s.executables = %w(ohai)
29
+
30
+ s.require_path = 'lib'
31
+ s.autorequire = GEM
32
+ s.files = %w(LICENSE README.rdoc Rakefile) + Dir.glob("{extras,lib,spec}/**/*")
33
+ end
34
+
35
+ task :default => :spec
36
+
37
+ desc "Run specs"
38
+ Spec::Rake::SpecTask.new do |t|
39
+ t.spec_files = FileList['spec/**/*_spec.rb']
40
+ t.spec_opts = %w(-fs --color)
41
+ end
42
+
43
+
44
+ Rake::GemPackageTask.new(spec) do |pkg|
45
+ pkg.gem_spec = spec
46
+ end
47
+
48
+ desc "install the gem locally"
49
+ task :install => [:package] do
50
+ sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
51
+ end
52
+
53
+ desc "create a gemspec file"
54
+ task :make_spec do
55
+ File.open("#{GEM}.gemspec", "w") do |file|
56
+ file.puts spec.to_ruby
57
+ end
58
+ end
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # ./ohai - I'm in ur serverz, showin you the daters
4
+ #
5
+ # Author:: Adam Jacob (<adam@opscode.com>)
6
+ # Copyright:: Copyright (c) 2008 Opscode, Inc.
7
+ # License:: Apache License, Version 2.0
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ #
21
+
22
+ $: << File.join(File.dirname(__FILE__), "..", "lib")
23
+ require 'optparse'
24
+ require 'rubygems'
25
+ require 'ohai'
26
+ require 'json'
27
+
28
+ config = {
29
+ :directory => nil,
30
+ :file => nil
31
+ }
32
+
33
+ opts = OptionParser.new do |opts|
34
+ opts.banner = "Usage: #{$0} (options)"
35
+ opts.on("-d", "--directory NAME", "A directory to add to the Ohai search path") do |d|
36
+ config[:directory] = d
37
+ end
38
+ opts.on("-f", "--file NAME", "A file to run Ohai against") do |f|
39
+ config[:file] = f
40
+ end
41
+ opts.on_tail("-h", "--help", "Show this message") do
42
+ puts opts
43
+ exit
44
+ end
45
+ end
46
+ opts.parse!(ARGV)
47
+
48
+ ohai = Ohai::System.new
49
+ if config[:file]
50
+ ohai.from_file(config[:file])
51
+ else
52
+ if config[:directory]
53
+ Ohai::Config[:plugin_path] << config[:directory]
54
+ end
55
+ ohai.all_plugins
56
+ end
57
+
58
+ puts ohai.json_pretty_print
@@ -0,0 +1,27 @@
1
+ #
2
+ # Author:: Adam Jacob (<adam@opscode.com>)
3
+ # Copyright:: Copyright (c) 2008 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ $:.unshift(File.dirname(__FILE__)) unless
20
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
21
+
22
+ require 'ohai/config'
23
+ require 'ohai/system'
24
+
25
+ module Ohai
26
+ VERSION = '0.1.2'
27
+ end
@@ -0,0 +1,118 @@
1
+ #
2
+ # Author:: Adam Jacob (<adam@opscode.com>)
3
+ # Copyright:: Copyright (c) 2008 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'ohai/mixin/from_file'
20
+
21
+ # Ohai::Config[:variable]
22
+ # @config = Ohai::Config.new()
23
+ # Ohai::Config.from_file(foo)
24
+ # Ohai::Config[:cookbook_path]
25
+ # Ohai::Config.cookbook_path
26
+ # Ohai::Config.cookbook_path "one", "two"
27
+
28
+ module Ohai
29
+ class Config
30
+
31
+ @configuration = {
32
+ :log_level => :info,
33
+ :log_location => STDOUT,
34
+ :plugin_path => [ File.expand_path(File.join(File.dirname(__FILE__), 'plugins')) ]
35
+ }
36
+
37
+ class << self
38
+ include Ohai::Mixin::FromFile
39
+
40
+ # Pass Ohai::Config.configure() a block, and it will yield @configuration.
41
+ #
42
+ # === Parameters
43
+ # <block>:: A block that takes @configure as it's argument
44
+ def configure(&block)
45
+ yield @configuration
46
+ end
47
+
48
+ # Get the value of a configuration option
49
+ #
50
+ # === Parameters
51
+ # config_option<Symbol>:: The configuration option to return
52
+ #
53
+ # === Returns
54
+ # value:: The value of the configuration option
55
+ #
56
+ # === Raises
57
+ # <ArgumentError>:: If the configuration option does not exist
58
+ def [](config_option)
59
+ if @configuration.has_key?(config_option.to_sym)
60
+ @configuration[config_option.to_sym]
61
+ else
62
+ raise ArgumentError, "Cannot find configuration option #{config_option.to_s}"
63
+ end
64
+ end
65
+
66
+ # Set the value of a configuration option
67
+ #
68
+ # === Parameters
69
+ # config_option<Symbol>:: The configuration option to set (within the [])
70
+ # value:: The value for the configuration option
71
+ #
72
+ # === Returns
73
+ # value:: The new value of the configuration option
74
+ def []=(config_option, value)
75
+ @configuration[config_option.to_sym] = value
76
+ end
77
+
78
+ # Check if Ohai::Config has a configuration option.
79
+ #
80
+ # === Parameters
81
+ # key<Symbol>:: The configuration option to check for
82
+ #
83
+ # === Returns
84
+ # <True>:: If the configuration option exists
85
+ # <False>:: If the configuration option does not exist
86
+ def has_key?(key)
87
+ @configuration.has_key?(key.to_sym)
88
+ end
89
+
90
+ # Allows for simple lookups and setting of configuration options via method calls
91
+ # on Ohai::Config. If there any arguments to the method, they are used to set
92
+ # the value of the configuration option. Otherwise, it's a simple get operation.
93
+ #
94
+ # === Parameters
95
+ # method_symbol<Symbol>:: The method called. Must match a configuration option.
96
+ # *args:: Any arguments passed to the method
97
+ #
98
+ # === Returns
99
+ # value:: The value of the configuration option.
100
+ #
101
+ # === Raises
102
+ # <ArgumentError>:: If the method_symbol does not match a configuration option.
103
+ def method_missing(method_symbol, *args)
104
+ if @configuration.has_key?(method_symbol)
105
+ if args.length == 1
106
+ @configuration[method_symbol] = args[0]
107
+ elsif args.length > 1
108
+ @configuration[method_symbol] = args
109
+ end
110
+ return @configuration[method_symbol]
111
+ else
112
+ raise ArgumentError, "Cannot find configuration option #{method_symbol.to_s}"
113
+ end
114
+ end
115
+
116
+ end # class << self
117
+ end
118
+ end