def edit(object)
unless Shef.editor
puts "Please set your editor with Shef.editor = \"vim|emacs|mate|ed\""
return :failburger
end
filename = "shef-edit-#{object.class.name}-"
if object.respond_to?(:name)
filename += object.name
elsif object.respond_to?(:id)
filename += object.id
end
edited_data = Tempfile.open([filename, ".js"]) do |tempfile|
tempfile.sync = true
tempfile.puts Chef::JSONCompat.to_json(object)
system("#{Shef.editor.to_s} #{tempfile.path}")
tempfile.rewind
tempfile.read
end
Chef::JSONCompat.from_json(edited_data)
end