Haruka Yoshihara
null+****@clear*****
Tue Dec 18 15:10:29 JST 2012
Haruka Yoshihara 2012-12-18 15:10:29 +0900 (Tue, 18 Dec 2012) New Revision: 74033bc9783a28fb6af626c7cce8d0b18f157303 https://github.com/groonga/groonga-query-log/commit/74033bc9783a28fb6af626c7cce8d0b18f157303 Log: Move codes shared with Analyzer and Extractor to the module Added files: lib/groonga/query-log/commandline-utils.rb Modified files: lib/groonga/query-log/analyzer.rb lib/groonga/query-log/extractor.rb Modified: lib/groonga/query-log/analyzer.rb (+3 -12) =================================================================== --- lib/groonga/query-log/analyzer.rb 2012-12-18 14:28:53 +0900 (e09c7b1) +++ lib/groonga/query-log/analyzer.rb 2012-12-18 15:10:29 +0900 (ec7a335) @@ -19,6 +19,7 @@ require "optparse" require "json" +require "groonga/query-log/commandline-utils" require "groonga/query-log/parser" require "groonga/query-log/analyzer/streamer" require "groonga/query-log/analyzer/sized-statistics" @@ -26,6 +27,8 @@ require "groonga/query-log/analyzer/sized-statistics" module Groonga module QueryLog class Analyzer + include CommandLineUtils + class Error < StandardError end @@ -214,18 +217,6 @@ module Groonga Groonga::QueryLog::StreamConsoleQueryLogReporter.new end end - - def log_via_stdin? - input_with_pipe? or input_with_redirect? - end - - def input_with_pipe? - File.pipe?($stdin) - end - - def input_with_redirect? - not File.select([$stdin], [], [], 0).nil? - end end end end Added: lib/groonga/query-log/commandline-utils.rb (+35 -0) 100755 =================================================================== --- /dev/null +++ lib/groonga/query-log/commandline-utils.rb 2012-12-18 15:10:29 +0900 (a460917) @@ -0,0 +1,35 @@ +#!/usr/bin/env ruby +# -*- coding: utf-8 -*- +# +# Copyright (C) 2012 Haruka Yoshihara <yoshihara �� clear-code.com> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1 as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +module Groonga + module QueryLog + module CommandLineUtils + def log_via_stdin? + input_with_pipe? or input_with_redirect? + end + + def input_with_pipe? + File.pipe?($stdin) + end + + def input_with_redirect? + not File.select([$stdin], [], [], 0).nil? + end + end + end +end Modified: lib/groonga/query-log/extractor.rb (+2 -12) =================================================================== --- lib/groonga/query-log/extractor.rb 2012-12-18 14:28:53 +0900 (96fd4d5) +++ lib/groonga/query-log/extractor.rb 2012-12-18 15:10:29 +0900 (7874a13) @@ -20,11 +20,13 @@ require "ostruct" require "optparse" require "pathname" +require "groonga/query-log/commandline-utils" require "groonga/query-log/parser" module Groonga module QueryLog class Extractor + include CommandLineUtils class Error < StandardError end @@ -166,18 +168,6 @@ module Groonga true end - - def log_via_stdin? - input_with_pipe? or input_with_redirect? - end - - def input_with_pipe? - File.pipe?($stdin) - end - - def input_with_redirect? - not File.select([$stdin], [], [], 0).nil? - end end end end -------------- next part -------------- HTML����������������������������... Download