[Groonga-commit] groonga/grntest [master] Reduce column width

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Nov 21 11:50:12 JST 2012


Kouhei Sutou	2012-11-21 11:50:12 +0900 (Wed, 21 Nov 2012)

  New Revision: b4e24eec66c29bf27d90428b43d71eb1ae900f58
  https://github.com/groonga/grntest/commit/b4e24eec66c29bf27d90428b43d71eb1ae900f58

  Log:
    Reduce column width

  Modified files:
    lib/grntest/tester.rb

  Modified: lib/grntest/tester.rb (+20 -19)
===================================================================
--- lib/grntest/tester.rb    2012-11-21 11:36:07 +0900 (dab1b2b)
+++ lib/grntest/tester.rb    2012-11-21 11:50:12 +0900 (06c6f30)
@@ -1774,29 +1774,30 @@ EOF
         puts(colorize(summary, result))
       end
 
-      def statistics_header
-        items = [
-          "tests/sec",
-          "tests",
-          "passes",
-          "failures",
-          "leaked",
-          "omitted",
-          "!checked",
+      def columns
+        [
+          # label,      format value
+          ["tests/sec", lambda {|result| "%9.2f" % throughput(result)}],
+          ["   tests",  lambda {|result| "%8d"   % result.n_tests}],
+          ["  passes",  lambda {|result| "%8d"   % result.n_passed_tests}],
+          ["failures",  lambda {|result| "%8d"   % result.n_failed_tests}],
+          ["  leaked",  lambda {|result| "%8d"   % result.n_leaked_tests}],
+          [" omitted",  lambda {|result| "%8d"   % result.n_omitted_tests}],
+          ["!checked",  lambda {|result| "%8d"   % result.n_not_checked_tests}],
         ]
-        "  " + ((["%-9s"] * items.size).join(" | ") % items) + " |"
+      end
+
+      def statistics_header
+        labels = columns.collect do |label, format_value|
+          label
+        end
+        "  " + labels.join(" | ") + " |"
       end
 
       def statistics(result)
-        items = [
-          "%9.2f" % throughput(result),
-          "%9d" % result.n_tests,
-          "%9d" % result.n_passed_tests,
-          "%9d" % result.n_failed_tests,
-          "%9d" % result.n_leaked_tests,
-          "%9d" % result.n_omitted_tests,
-          "%9d" % result.n_not_checked_tests,
-        ]
+        items = columns.collect do |label, format_value|
+          format_value.call(result)
+        end
         "  " + items.join(" | ") + " |"
       end
 
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index