Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'activesupport_fixes'

  • Loading branch information...
commit 6fa7cb289a69c8b3e0b1e13bf45cc039efab51e9 2 parents 9bbc717 + fcbf713
@mmzyk mmzyk authored
View
8 chef/lib/chef/handler/json_file.rb
@@ -41,7 +41,13 @@ def report
build_report_dir
savetime = Time.now.strftime("%Y%m%d%H%M%S")
File.open(File.join(config[:path], "chef-run-report-#{savetime}.json"), "w") do |file|
- file.puts Chef::JSONCompat.to_json_pretty(data)
+
+ #ensure start time and end time are output in the json properly in the event activesupport happens to be on the system
+ run_data = data
+ run_data[:start_time] = run_data[:start_time].to_s
+ run_data[:end_time] = run_data[:end_time].to_s
+
+ file.puts Chef::JSONCompat.to_json_pretty(run_data)
end
end
View
11 chef/lib/chef/resource.rb
@@ -346,8 +346,10 @@ def inspect
end << ">"
end
- # Serialize this object as a hash
- def to_json(*a)
+ # as_json does most of the to_json heavy lifted. It exists here in case activesupport
+ # is loaded. activesupport will call as_json and skip over to_json. This ensure
+ # json is encoded as expected
+ def as_json(*a)
safe_ivars = instance_variables.map { |ivar| ivar.to_sym } - FORBIDDEN_IVARS
instance_vars = Hash.new
safe_ivars.each do |iv|
@@ -357,6 +359,11 @@ def to_json(*a)
'json_class' => self.class.name,
'instance_vars' => instance_vars
}
+ end
+
+ # Serialize this object as a hash
+ def to_json(*a)
+ results = as_json
results.to_json(*a)
end
View
2  chef/lib/chef/run_list.rb
@@ -85,7 +85,7 @@ def to_s
end
def to_json(*args)
- to_a.to_json(*args)
+ to_a.map { |item| item.to_s}.to_json(*args)
end
def empty?
Please sign in to comment.
Something went wrong with that request. Please try again.