Paired-with: Jesse Wolfe <[email protected]>
Signed-off-by: Paul Berry <[email protected]>
---
Local-branch: ticket/next/5743
lib/report_transformer.rb | 9 ++++++++-
spec/lib/report_transformer_spec.rb | 7 +++++++
2 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/lib/report_transformer.rb b/lib/report_transformer.rb
index c7ecc13..e4fdd46 100644
--- a/lib/report_transformer.rb
+++ b/lib/report_transformer.rb
@@ -45,7 +45,14 @@ class ReportTransformer::OneToTwo <
ReportTransformer::ReportTransformation
end
def self.transform(report)
- if report["metrics"] and report["metrics"]["time"] and
!report["metrics"]["time"]["total"]
+ report["metrics"].keys.each do |metric_category|
+ new_metrics = {}
+ report["metrics"][metric_category].each do |metric_name, value|
+ new_metrics[metric_name.to_s] = value
+ end
+ report["metrics"][metric_category] = new_metrics
+ end
+ if report["metrics"]["time"] and !report["metrics"]["time"]["total"]
report["metrics"]["time"]["total"] = report["metrics"]["time"].values.sum
end
diff --git a/spec/lib/report_transformer_spec.rb
b/spec/lib/report_transformer_spec.rb
index b7643b4..9b5b6ec 100644
--- a/spec/lib/report_transformer_spec.rb
+++ b/spec/lib/report_transformer_spec.rb
@@ -201,5 +201,12 @@ describe ReportTransformer do
end
end
end
+
+ it "should translate metric names to strings" do
+ @report["metrics"]["time"][:file] = 3.125
+ report = ReportTransformer::OneToTwo.apply(@report)
+ report["metrics"]["time"]["file"].should == 3.125
+ report["metrics"]["time"].keys.should_not include(:file)
+ end
end
end
--
1.7.2
--
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en.