Class: Groonga::Client::CommandLine::GroongaClient
- Inherits:
-
Object
- Object
- Groonga::Client::CommandLine::GroongaClient
- Defined in:
- lib/groonga/client/command-line/groonga-client.rb
Defined Under Namespace
Classes: Runner
Instance Method Summary collapse
-
#initialize ⇒ GroongaClient
constructor
A new instance of GroongaClient.
- #run(arguments) ⇒ Object
Constructor Details
#initialize ⇒ GroongaClient
Returns a new instance of GroongaClient.
29 30 31 32 33 34 35 36 |
# File 'lib/groonga/client/command-line/groonga-client.rb', line 29 def initialize @chunk = false @runner_options = { :split_load_chunk_size => 10000, :generate_request_id => false, } end |
Instance Method Details
#run(arguments) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/groonga/client/command-line/groonga-client.rb', line 38 def run(arguments) parser = Parser.new command_file_paths = parser.parse(arguments) do |option_parser| parse_command_line(option_parser) end parser.open_client(:chunk => @chunk) do |client| runner = Runner.new(client, @runner_options) if command_file_paths.empty? $stdin.each_line do |line| runner << line end else command_file_paths.each do |command_file_path| File.open(command_file_path) do |command_file| last_line = nil command_file.each_line do |line| last_line = line runner << line end if last_line and !last_line.end_with?("\n") runner << "\n" end end end end runner.finish end true end |