Skip to content
This repository

Stats generator was crashing if 'rake stats' outputted any blank lines #59

Closed
wants to merge 1 commit into from

3 participants

Casey Howard Jake Scruggs Benjamin Fleischer
Casey Howard

Fixed the stats generator to not crash when blank lines appear in the output of 'rake stats'. One reason this occurs is if there are deprecation warnings.

Fixed the stats generator to not crash when blank lines appear in the…
… output of 'rake stats'. One reason this occurs is if there are deprecation warnings.
8bfefed
Jake Scruggs
Owner

This may have been fixed by 03c02d3

Could you let me know?

Casey Howard

Yes. It was. I think the spec would still be good to update though. What do you think?

Benjamin Fleischer bf4 referenced this pull request in metricfu/metric_fu
Merged

Fix #24 handle empty stats output #103

Benjamin Fleischer
Collaborator

Gem no longer maintained, See https://github.com/metricfu/metric_fu

Benjamin Fleischer bf4 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Feb 10, 2011
Fixed the stats generator to not crash when blank lines appear in the…
… output of 'rake stats'. One reason this occurs is if there are deprecation warnings.
8bfefed
This page is out of date. Refresh to see the latest.
3  lib/generators/stats.rb
@@ -26,8 +26,7 @@ def to_h
26 26
 
27 27
     def remove_noise(output)
28 28
       lines = output.split("\n")
29  
-      lines = lines.find_all {|line| line[0].chr != "+" }
30  
-      lines = lines.find_all {|line| line[0].chr != "(" }
  29
+      lines.reject! { |line| line.empty? || ['+', '('].include?(line[0].chr) }
31 30
       lines.shift
32 31
       lines
33 32
     end
12  spec/generators/stats_spec.rb
@@ -13,7 +13,17 @@
13 13
 
14 14
   describe "analyze method" do
15 15
     before :each do
16  
-      @lines =  <<-HERE.gsub(/^\s*/, "")
  16
+      @lines =  <<-HERE
  17
+      The 'run' provides a unified access point for all the default Rails' commands.
  18
+
  19
+      Usage: ./script/run <command> [OPTIONS]
  20
+
  21
+      Examples:
  22
+        ./script/run generate controller Admin
  23
+        ./script/run process reaper
  24
+
  25
+      Choose: about, console, dbconsole, destroy, generate, plugin, runner, server, update
  26
+
17 27
       +----------------------+-------+-------+---------+---------+-----+-------+
18 28
       | Name                 | Lines |   LOC | Classes | Methods | M/C | LOC/M |
19 29
       +----------------------+-------+-------+---------+---------+-----+-------+
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.