Closed kamaradclimber closed 10 years ago
I'm going to try to refactor that code, it was already a mess before. We should be able to use classes from Chef to avoid reinventing the wheel. Thanks for the pull request!
@gregkare agreed that some of this code duplicate chef code
Here's what I came up with:
def local_items
cl = Chef::CookbookLoader.new(@context.cookbook_path)
cl.load_cookbooks
cl.inject({}) do |hash, (name, cookbook_version)|
hash[name] = Chef::Version.new(cookbook_version.version)
hash
end
end
It still passes the tests, now checking how it behaves when there's both a json and rb file
It loads the metadata.rb first when it exists, nice. Do you want to rebase your pull request to do this instead? I'm always happy to see some code get deleted :)
Edit: Chef::CookbookLoader
exists in Chef 10 too, so it should work there too
https://github.com/opscode/chef/blob/master/lib/chef/cookbook/cookbook_version_loader.rb#L107
rb first, then json, then a new object that I didn't know about: uploaded_cookbook_version_file
this PR can be closed then
Ok, I'll do a pull request then, I've also used a metadata.json file in spec/chef-repo/cookbooks/cookbook_two
. Thanks!
Berkshelf vendors cookbooks with compiled metadata file (in json) instead of metadata.rb. We test for both and prefer rb format
fixes bmarini/knife-inspect#5