Skip to content

Commit

Permalink
Adding compatibility with Chef 11
Browse files Browse the repository at this point in the history
  • Loading branch information
kdaniels committed Jul 27, 2016
1 parent e77badc commit a682f47
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -6,6 +6,7 @@ rvm:
env:
- CHEF_VERSION=12.6.0
- CHEF_VERSION=12.7.2
- CHEF_VERSION=11.18.2
notifications:
email: false
sudo: false
3 changes: 1 addition & 2 deletions README.md
Expand Up @@ -68,8 +68,7 @@ when everything is in sync or 1 if it's not.

## Compatibility

This gem is tested with Ruby 2.1 and 2.2 and should be compatible with Chef
10, 11 and 12.
This gem is tested with Ruby 2.1 and 2.2 and has been tested with Chef 12 and Chef 11.

## Contributors

Expand Down
12 changes: 10 additions & 2 deletions lib/health_inspector/checklists/base.rb
Expand Up @@ -141,9 +141,17 @@ def load_ruby_or_json_from_local(chef_class, folder, name)
instance = chef_class.new
instance.from_file(ruby_pathname.first.to_s)
elsif !json_pathname.empty?
instance = chef_class.from_hash(Yajl::Parser.parse(json_pathname.first.read))
if Chef::VERSION.start_with? "12"
instance = chef_class.from_hash(Yajl::Parser.parse(json_pathname.first.read))
else
instance = chef_class.json_create(Yajl::Parser.parse(json_pathname.first.read))
end
elsif !js_pathname.empty?
instance = chef_class.from_hash(Yajl::Parser.parse(js_pathname.first.read))
if Chef::VERSION.start_with? "12"
instance = chef_class.from_hash(Yajl::Parser.parse(js_pathname.first.read))
else
instance = chef_class.json_create(Yajl::Parser.parse(js_pathname.first.read))
end
end

instance ? instance.to_hash : nil
Expand Down

0 comments on commit a682f47

Please sign in to comment.