Method: Berkshelf::CachedCookbook#compile_metadata

Defined in:
lib/berkshelf/cached_cookbook.rb

#compile_metadata(path = self.path) ⇒ Object



166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/berkshelf/cached_cookbook.rb', line 166

def (path = self.path)
  json_file = "#{path}/metadata.json"
  rb_file = "#{path}/metadata.rb"
  return nil if File.exist?(json_file)

  md = Chef::Cookbook::Metadata.new
  md.from_file(rb_file)
  f = File.open(json_file, "w")
  f.write(Chef::JSONCompat.to_json_pretty(md))
  f.close
  f.path
end