Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'activesupport_fixes'

  • Loading branch information...
commit 6fa7cb289a69c8b3e0b1e13bf45cc039efab51e9 2 parents 9bbc717 + fcbf713
Mark Mzyk mmzyk authored
8 chef/lib/chef/handler/json_file.rb
@@ -41,7 +41,13 @@ def report
41 41 build_report_dir
42 42 savetime = Time.now.strftime("%Y%m%d%H%M%S")
43 43 File.open(File.join(config[:path], "chef-run-report-#{savetime}.json"), "w") do |file|
44   - file.puts Chef::JSONCompat.to_json_pretty(data)
  44 +
  45 + #ensure start time and end time are output in the json properly in the event activesupport happens to be on the system
  46 + run_data = data
  47 + run_data[:start_time] = run_data[:start_time].to_s
  48 + run_data[:end_time] = run_data[:end_time].to_s
  49 +
  50 + file.puts Chef::JSONCompat.to_json_pretty(run_data)
45 51 end
46 52 end
47 53
11 chef/lib/chef/resource.rb
@@ -346,8 +346,10 @@ def inspect
346 346 end << ">"
347 347 end
348 348
349   - # Serialize this object as a hash
350   - def to_json(*a)
  349 + # as_json does most of the to_json heavy lifted. It exists here in case activesupport
  350 + # is loaded. activesupport will call as_json and skip over to_json. This ensure
  351 + # json is encoded as expected
  352 + def as_json(*a)
351 353 safe_ivars = instance_variables.map { |ivar| ivar.to_sym } - FORBIDDEN_IVARS
352 354 instance_vars = Hash.new
353 355 safe_ivars.each do |iv|
@@ -357,6 +359,11 @@ def to_json(*a)
357 359 'json_class' => self.class.name,
358 360 'instance_vars' => instance_vars
359 361 }
  362 + end
  363 +
  364 + # Serialize this object as a hash
  365 + def to_json(*a)
  366 + results = as_json
360 367 results.to_json(*a)
361 368 end
362 369
2  chef/lib/chef/run_list.rb
@@ -85,7 +85,7 @@ def to_s
85 85 end
86 86
87 87 def to_json(*args)
88   - to_a.to_json(*args)
  88 + to_a.map { |item| item.to_s}.to_json(*args)
89 89 end
90 90
91 91 def empty?

0 comments on commit 6fa7cb2

Please sign in to comment.
Something went wrong with that request. Please try again.