Class: Groonga::QueryLog::Extractor
- Inherits:
-
Object
- Object
- Groonga::QueryLog::Extractor
- Includes:
- CommandLineUtils
- Defined in:
- lib/groonga/query-log/extractor.rb
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#option_parser ⇒ Object
readonly
Returns the value of attribute option_parser.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize ⇒ Extractor
constructor
A new instance of Extractor.
-
#run(arguments) ⇒ Object
Executes extractor for groonga’s query logs.
Methods included from CommandLineUtils
#log_via_stdin?, #stdin_with_pipe?, #stdin_with_redirect?
Constructor Details
#initialize ⇒ Extractor
Returns a new instance of Extractor.
37 38 39 40 41 |
# File 'lib/groonga/query-log/extractor.rb', line 37 def initialize @options = nil @option_parser = nil end |
Instance Attribute Details
#option_parser ⇒ Object (readonly)
Returns the value of attribute option_parser.
35 36 37 |
# File 'lib/groonga/query-log/extractor.rb', line 35 def option_parser @option_parser end |
#options ⇒ Object
Returns the value of attribute options.
34 35 36 |
# File 'lib/groonga/query-log/extractor.rb', line 34 def @options end |
Instance Method Details
#run(arguments) ⇒ Object
Executes extractor for groonga’s query logs. “groonga-query-log-extract” command runs this method.
If only paths of query log files are specified, this method prints command(s) of them to console.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/groonga/query-log/extractor.rb', line 58 def run(arguments) begin log_paths = @option_parser.parse!(arguments) rescue OptionParser::ParseError $stderr.puts($!.) return false end if log_paths.empty? unless log_via_stdin? $stderr.puts("Error: Please specify input log files.") return false end log = $stdin else log = log_paths end if @options.output_path File.open(@options.output_path, "w") do |output| extract(log, output) end else extract(log, $stdout) end true end |