Sha256: 2000e8e7e7cd0ecdeca809ee2762be4b82102cf397348bd99d5e4bbdd37a0d4f
Contents?: true
Size: 644 Bytes
Versions: 13
Compression:
Stored size: 644 Bytes
Contents
require 'chef/knife/core/object_loader' require 'yaml' class Chef::Knife::Core::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) @klass.json_create(r) else ui.fatal("File must end in .js, .json, .rb or .yml") exit 30 end end end
Version data entries
13 entries across 13 versions & 1 rubygems