Navigation Menu

Skip to content

Commit

Permalink
Reduce scope
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Oct 26, 2017
1 parent 3d6bfb2 commit 2041ee5
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions lib/groonga/client/command-line/groonga-client.rb
Expand Up @@ -45,34 +45,35 @@ def initialize
def run(argv)
command_file_paths = parse_command_line(argv)

@client = Client.new(:url => @url,
:protocol => @protocol,
:host => @host,
:port => @port,
:read_timeout => @read_timeout,
:chunk => @chunk,
:backend => :synchronous)
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
Client.open(:url => @url,
:protocol => @protocol,
:host => @host,
:port => @port,
:read_timeout => @read_timeout,
:chunk => @chunk,
:backend => :synchronous) 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"
if last_line and !last_line.end_with?("\n")
runner << "\n"
end
end
end
end
runner.finish
end
runner.finish

true
end
Expand Down

0 comments on commit 2041ee5

Please sign in to comment.