With this commit to ohai: http://github.com/opscode/ohai/commit/f89baccc3b9ab587d23e0b6257f6fedffe223c02
However, if you remove 'json, 'json_pure', then run 'rake spec' from another project [chef] that requires ohai (HAS NOT BEEN SWITCHED TO YAJL YET):
aj@AJ-Christensens-MacBook (branch: master) ~/Development/chef/chef$ rake spec
(in /Users/aj/Development/chef/chef) /Users/aj/.gem/ruby/1.8/gems/yajl-ruby-0.6.3/lib/yajl/json_gem/parsing.rb:5: superclass mismatch for class ParserError (TypeError)
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /Users/aj/.gem/ruby/1.8/gems/yajl-ruby-0.6.3/lib/yajl/json_gem.rb:3
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /opt/local/lib/ruby/gems/1.8/gems/ohai-0.3.4/lib/ohai/system.rb:27
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /opt/local/lib/ruby/gems/1.8/gems/ohai-0.3.4/lib/ohai.rb:23
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /Users/aj/Development/chef/chef/spec/../lib/chef/client.rb:31
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /Users/aj/Development/chef/chef/spec/../lib/chef/application/client.rb:19
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /Users/aj/Development/chef/chef/spec/spec_helper.rb:34
from /Users/aj/Development/chef/chef/spec/spec_helper.rb:26:in `each'
from /Users/aj/Development/chef/chef/spec/spec_helper.rb:26
from ./spec/unit/client_spec.rb:19:in `require'
from ./spec/unit/client_spec.rb:19
Any ideas? chef project ticket ref# http://tickets.opscode.com/browse/CHEF-592
Changing the require to straight up 'yajl' supposedly works, although I haven't verified this.
Please see my fork for an implementation...
Was just taking a look at that, awesome!
Ok so I pulled down the patch and played with it a bit.
Everything looks good except the sort option used in conjunction with a Hash that has Symbols for keys will fail to sort because the Symbol class doesn't have a <=> method out of the box.
I have a couple of ideas for how to handle that, but I wanted to see what you thought in case this is a use-case you'd need to cover for your own needs as well?
Since all of my keys are strings, I didn't test that case... A graceful fallback when the keys can't be sorted would be nice.
Another case that fails are mixed keys (Strings and Fixnum and Symbols)...
Since I don't have any strong opinion about the "correct" sort order, how about something in the spirit of this:
a.sort_by {|x| [x.class.to_s, (x.respond_to? :to_s)? x.to_s : x.inspect]}
This would group keys by their class and sort them by some kind of string representation, falling back to ".inspect" if there is no to_s defined...