Skip to content

Commit

Permalink
OHAI-95: support YAJL > JSON > JSON pure
Browse files Browse the repository at this point in the history
Removes the direct dependency on a JSON library, allowing for user
choice.

Recommended use of YAJL, it's far quicker.
  • Loading branch information
AJ Christensen committed Oct 6, 2009
1 parent 1795eb3 commit f89bacc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
*.swp
pkg/
tmp/
coverage/
Expand Down
1 change: 0 additions & 1 deletion Rakefile
Expand Up @@ -22,7 +22,6 @@ spec = Gem::Specification.new do |s|
s.email = EMAIL
s.homepage = HOMEPAGE

s.add_dependency "json"
s.add_dependency "extlib"
s.add_dependency "systemu"
s.add_dependency "mixlib-cli"
Expand Down
16 changes: 15 additions & 1 deletion lib/ohai/system.rb
Expand Up @@ -22,7 +22,21 @@
require 'ohai/mixin/from_file'
require 'ohai/mixin/command'
require 'ohai/mixin/string'
require 'json'

begin
require 'yajl/json_gem'
rescue LoadError
begin
require 'json'
rescue LoadError
begin
require 'json/pure'
rescue LoadError
STDERR.puts "No valid JSON library detected, please install one of 'yajl-ruby', 'json' or 'json-pure'."
exit -2
end
end
end

module Ohai
class System
Expand Down

0 comments on commit f89bacc

Please sign in to comment.