Class: GroongaQueryLog::Command::Extract
- Inherits:
-
GroongaQueryLog::CommandLine
- Object
- GroongaQueryLog::CommandLine
- GroongaQueryLog::Command::Extract
- Defined in:
- lib/groonga-query-log/command/extract.rb
Defined Under Namespace
Classes: DumpFormatter, InspectFormatter
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 ⇒ Extract
constructor
A new instance of Extract.
-
#run(arguments) ⇒ Object
Executes extractor for Groonga’s query logs.
Constructor Details
#initialize ⇒ Extract
Returns a new instance of Extract.
31 32 33 34 35 |
# File 'lib/groonga-query-log/command/extract.rb', line 31 def initialize @options = nil @option_parser = nil end |
Instance Attribute Details
#option_parser ⇒ Object (readonly)
Returns the value of attribute option_parser.
29 30 31 |
# File 'lib/groonga-query-log/command/extract.rb', line 29 def option_parser @option_parser end |
#options ⇒ Object
Returns the value of attribute options.
28 29 30 |
# File 'lib/groonga-query-log/command/extract.rb', line 28 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.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/groonga-query-log/command/extract.rb', line 52 def run(arguments) begin log_paths = @option_parser.parse!(arguments) rescue OptionParser::ParseError $stderr.puts($!.) return false end begin if @options.output File.open(@options.output, "w") do |output| extract(log_paths, output) end else extract(log_paths, $stdout) end rescue Interrupt, Errno::EPIPE rescue Error $stderr.puts($!.) return false end true end |