Sha256: c622cbcec178670772a918fc1e181ecbe30e0ca210884706430cc1d254af3037
Contents?: true
Size: 852 Bytes
Versions: 2
Compression:
Stored size: 852 Bytes
Contents
COOKBOOKS_DIR = File.expand_path('../cookbooks', __FILE__) ROLE_DIR = File.expand_path('../roles', __FILE__) require 'chef' require 'posix/spawn' namespace :roles do desc "Convert ruby roles from ruby to json, creating/overwriting json files." task :to_json do Dir.glob(File.join(ROLE_DIR, '*.rb')) do |rb_file| role = Chef::Role.new role.from_file(rb_file) json_file = rb_file.sub(/\.rb$/,'.json') File.open(json_file, 'w'){|f| f.write(JSON.pretty_generate(role))} end end end namespace :metadata do desc "Convert all metadata from ruby to json." task :to_json do Dir.glob(File.join(COOKBOOKS_DIR, '*/metadata.rb')) do |rb_file| path = rb_file.split('/')[-3] recipe = rb_file.split('/')[-2] POSIX::Spawn::spawn("knife cookbook metadata -o #{path} #{recipe}") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
m2r-2.1.0 | kitchen/Rakefile |
m2r-2.1.0.pre | kitchen/Rakefile |