[Groonga-commit] groonga/groonga-query-log at 63aeafb [master] Extract parsing code as a method

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Dec 6 11:27:07 JST 2013


Kouhei Sutou	2013-12-06 11:27:07 +0900 (Fri, 06 Dec 2013)

  New Revision: 63aeafb12ece38c884b04648c51aca79bd16a068
  https://github.com/groonga/groonga-query-log/commit/63aeafb12ece38c884b04648c51aca79bd16a068

  Message:
    Extract parsing code as a method

  Modified files:
    lib/groonga/query-log/analyzer.rb

  Modified: lib/groonga/query-log/analyzer.rb (+17 -13)
===================================================================
--- lib/groonga/query-log/analyzer.rb    2013-12-06 11:24:29 +0900 (8283413)
+++ lib/groonga/query-log/analyzer.rb    2013-12-06 11:27:07 +0900 (48e89d7)
@@ -64,7 +64,6 @@ module Groonga
         dynamic_sort = @options[:dynamic_sort]
         statistics = SizedStatistics.new
         statistics.apply_options(@options)
-        parser = Groonga::QueryLog::Parser.new
         if stream
           streamer = Streamer.new(create_reporter(statistics))
           streamer.start
@@ -82,18 +81,7 @@ module Groonga
           end
         end
 
-        if log_paths.empty?
-          unless log_via_stdin?
-            raise(NoInputError, "Error: Please specify input log files.")
-          end
-          parser.parse($stdin, &process_statistic)
-        end
-
-        log_paths.each do |log_path|
-          File.open(log_path) do |log|
-            parser.parse(log, &process_statistic)
-          end
-        end
+        parse(log_paths, &process_statistic)
         if stream
           streamer.finish
           return
@@ -232,6 +220,22 @@ module Groonga
           Groonga::QueryLog::StreamConsoleQueryLogReporter.new
         end
       end
+
+      def parse(log_paths, &process_statistic)
+        parser = Groonga::QueryLog::Parser.new
+        if log_paths.empty?
+          unless log_via_stdin?
+            raise(NoInputError, "Error: Please specify input log files.")
+          end
+          parser.parse($stdin, &process_statistic)
+        end
+
+        log_paths.each do |log_path|
+          File.open(log_path) do |log|
+            parser.parse(log, &process_statistic)
+          end
+        end
+      end
     end
   end
 end
-------------- next part --------------
HTML����������������������������...
下载 



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