Sha256: ece3dd68f10ea04908589c79c7e56239f699a6a553af2c7bcfc84b153a140c3a
Contents?: true
Size: 882 Bytes
Versions: 1
Compression:
Stored size: 882 Bytes
Contents
require 'chef/knife' require 'yaml' class Chef class Knife module Core class ObjectLoader def object_from_file(filename) case filename when /\.(js|json)$/ r = Yajl::Parser.parse(IO.read(filename)) # Chef::DataBagItem doesn't work well with the json_create method if @klass == Chef::DataBagItem r else @klass.json_create(r) end when /\.rb$/ r = klass.new r.from_file(filename) r when /\.yml$/ r = YAML.load_file(filename) puts "r: #{r}" @klass.json_create(r.to_json) else ui.fatal("File must end in .js, .json, .rb or .yml") exit 30 end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
knife-undev-0.0.1 | lib/knife/undev/monkey_patches/object_loader.rb |