Renamed Puppet::Transaction::Report#calculate_metrics to
finalize_report, in preparation for adding more functionality to this
method.

Removed Puppet::Transaction#send_report and
Puppet::Transaction#generate_report.  The former was never used, and
the latter was unnecessary.

Signed-off-by: Paul Berry <[email protected]>
---
 lib/puppet/application/inspect.rb    |    2 +-
 lib/puppet/configurer.rb             |    4 ++--
 lib/puppet/transaction.rb            |   26 --------------------------
 lib/puppet/transaction/report.rb     |    2 +-
 spec/unit/configurer_spec.rb         |   22 +++++++---------------
 spec/unit/transaction/report_spec.rb |   20 ++++++++++----------
 spec/unit/transaction_spec.rb        |    5 -----
 7 files changed, 21 insertions(+), 60 deletions(-)

diff --git a/lib/puppet/application/inspect.rb 
b/lib/puppet/application/inspect.rb
index e6c35ea..2f068a2 100644
--- a/lib/puppet/application/inspect.rb
+++ b/lib/puppet/application/inspect.rb
@@ -70,7 +70,7 @@ class Puppet::Application::Inspect < Puppet::Application
 
     finishtime = Time.now
     @report.add_times("inspect", finishtime - inspect_starttime)
-    @report.calculate_metrics
+    @report.finalize_report
 
     begin
       @report.save
diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb
index 0701765..d3c9025 100644
--- a/lib/puppet/configurer.rb
+++ b/lib/puppet/configurer.rb
@@ -170,8 +170,8 @@ class Puppet::Configurer
     send_report(report, transaction)
   end
 
-  def send_report(report, trans = nil)
-    trans.generate_report if trans
+  def send_report(report, trans)
+    report.finalize_report if trans
     puts report.summary if Puppet[:summarize]
     report.save if Puppet[:report]
   rescue => detail
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index 4db9714..aa650ee 100644
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@ -221,12 +221,6 @@ class Puppet::Transaction
     end
   end
 
-  # Generate a transaction report.
-  def generate_report
-    @report.calculate_metrics
-    @report
-  end
-
   # Should we ignore tags?
   def ignore_tags?
     ! (@catalog.host_config? or Puppet[:name] == "puppet")
@@ -284,26 +278,6 @@ class Puppet::Transaction
     catalog.relationship_graph
   end
 
-  # Send off the transaction report.
-  def send_report
-    begin
-      report = generate_report
-    rescue => detail
-      Puppet.err "Could not generate report: #{detail}"
-      return
-    end
-
-    puts report.summary if Puppet[:summarize]
-
-    if Puppet[:report]
-      begin
-        report.save
-      rescue => detail
-        Puppet.err "Reporting failed: #{detail}"
-      end
-    end
-  end
-
   def add_resource_status(status)
     report.add_resource_status status
   end
diff --git a/lib/puppet/transaction/report.rb b/lib/puppet/transaction/report.rb
index b40c856..6eac651 100644
--- a/lib/puppet/transaction/report.rb
+++ b/lib/puppet/transaction/report.rb
@@ -43,7 +43,7 @@ class Puppet::Transaction::Report
     @resource_statuses[status.resource] = status
   end
 
-  def calculate_metrics
+  def finalize_report
     calculate_resource_metrics
     calculate_time_metrics
     calculate_change_metrics
diff --git a/spec/unit/configurer_spec.rb b/spec/unit/configurer_spec.rb
index 3b2a44f..cf73a37 100755
--- a/spec/unit/configurer_spec.rb
+++ b/spec/unit/configurer_spec.rb
@@ -233,16 +233,8 @@ describe Puppet::Configurer, "when sending a report" do
     @trans = stub 'transaction'
   end
 
-  it "should require a report" do
-    lambda { @configurer.send_report }.should raise_error(ArgumentError)
-  end
-
-  it "should allow specification of a transaction" do
-    lambda { @configurer.send_report(@report, @trans)  }.should_not 
raise_error(ArgumentError)
-  end
-
-  it "should use any provided transaction to add metrics to the report" do
-    @trans.expects(:generate_report)
+  it "should finalize the report" do
+    @report.expects(:finalize_report)
     @configurer.send_report(@report, @trans)
   end
 
@@ -252,28 +244,28 @@ describe Puppet::Configurer, "when sending a report" do
     @report.expects(:summary).returns "stuff"
 
     @configurer.expects(:puts).with("stuff")
-    @configurer.send_report(@report)
+    @configurer.send_report(@report, nil)
   end
 
   it "should not print a report summary if not configured to do so" do
     Puppet.settings[:summarize] = false
 
     @configurer.expects(:puts).never
-    @configurer.send_report(@report)
+    @configurer.send_report(@report, nil)
   end
 
   it "should save the report if reporting is enabled" do
     Puppet.settings[:report] = true
 
     @report.expects(:save)
-    @configurer.send_report(@report)
+    @configurer.send_report(@report, nil)
   end
 
   it "should not save the report if reporting is disabled" do
     Puppet.settings[:report] = false
 
     @report.expects(:save).never
-    @configurer.send_report(@report)
+    @configurer.send_report(@report, nil)
   end
 
   it "should log but not fail if saving the report fails" do
@@ -282,7 +274,7 @@ describe Puppet::Configurer, "when sending a report" do
     @report.expects(:save).raises "whatever"
 
     Puppet.expects(:err)
-    lambda { @configurer.send_report(@report) }.should_not raise_error
+    lambda { @configurer.send_report(@report, nil) }.should_not raise_error
   end
 end
 
diff --git a/spec/unit/transaction/report_spec.rb 
b/spec/unit/transaction/report_spec.rb
index 8c4ed8a..98be287 100755
--- a/spec/unit/transaction/report_spec.rb
+++ b/spec/unit/transaction/report_spec.rb
@@ -145,7 +145,7 @@ describe Puppet::Transaction::Report do
 
     [:time, :resources, :changes, :events].each do |type|
       it "should add #{type} metrics" do
-        @report.calculate_metrics
+        @report.finalize_report
         @report.metrics[type.to_s].should 
be_instance_of(Puppet::Transaction::Metric)
       end
     end
@@ -154,7 +154,7 @@ describe Puppet::Transaction::Report do
       it "should provide the total number of resources" do
         add_statuses(3)
 
-        @report.calculate_metrics
+        @report.finalize_report
         metric(:resources, :total).should == 3
       end
 
@@ -162,7 +162,7 @@ describe Puppet::Transaction::Report do
         it "should provide the number of #{state} resources as determined by 
the status objects" do
           add_statuses(3) { |status| status.send(state.to_s + "=", true) }
 
-          @report.calculate_metrics
+          @report.finalize_report
           metric(:resources, state).should == 3
         end
       end
@@ -171,7 +171,7 @@ describe Puppet::Transaction::Report do
     describe "for changes" do
       it "should provide the number of changes from the resource statuses" do
         add_statuses(3) { |status| 3.times { status << 
Puppet::Transaction::Event.new(:status => 'success') } }
-        @report.calculate_metrics
+        @report.finalize_report
         metric(:changes, :total).should == 9
       end
     end
@@ -188,7 +188,7 @@ describe Puppet::Transaction::Report do
           status.evaluation_time = 3
         end
 
-        @report.calculate_metrics
+        @report.finalize_report
 
         metric(:time, "file").should == 3
         metric(:time, "exec").should == 6
@@ -197,7 +197,7 @@ describe Puppet::Transaction::Report do
 
       it "should add any provided times from external sources" do
         @report.add_times :foobar, 50
-        @report.calculate_metrics
+        @report.finalize_report
         metric(:time, "foobar").should == 50
       end
 
@@ -206,7 +206,7 @@ describe Puppet::Transaction::Report do
           status.evaluation_time = 1.25
         end
         @report.add_times :config_retrieval, 0.5
-        @report.calculate_metrics
+        @report.finalize_report
         metric(:time, "total").should == 4.25
       end
     end
@@ -216,7 +216,7 @@ describe Puppet::Transaction::Report do
         add_statuses(3) do |status|
           3.times { |i| status.add_event(Puppet::Transaction::Event.new) }
         end
-        @report.calculate_metrics
+        @report.finalize_report
         metric(:events, :total).should == 9
       end
 
@@ -230,7 +230,7 @@ describe Puppet::Transaction::Report do
             end
           end
 
-          @report.calculate_metrics
+          @report.finalize_report
           metric(:events, status_name).should == 9
         end
       end
@@ -245,7 +245,7 @@ describe Puppet::Transaction::Report do
       trans = catalog.apply
 
       @report = trans.report
-      @report.calculate_metrics
+      @report.finalize_report
     end
 
     %w{Changes Total Resources}.each do |main|
diff --git a/spec/unit/transaction_spec.rb b/spec/unit/transaction_spec.rb
index 566c904..862413a 100755
--- a/spec/unit/transaction_spec.rb
+++ b/spec/unit/transaction_spec.rb
@@ -58,11 +58,6 @@ describe Puppet::Transaction do
     @transaction.report.resource_statuses[resource.to_s].should equal(status)
   end
 
-  it "should calculate metrics on and report the report when asked to generate 
a report" do
-    @transaction.report.expects(:calculate_metrics)
-    @transaction.generate_report.should equal(@transaction.report)
-  end
-
   it "should consider a resource to be failed if a status instance exists for 
that resource and indicates it is failed" do
     resource = Puppet::Type.type(:notify).new :name => "yayness"
     status = Puppet::Resource::Status.new(resource)
-- 
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.

Reply via email to