groonga-client-cli 1.0.3 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cec98629d85e45b31f3cb92744e4638d601d55b9
4
- data.tar.gz: de5fae05fd79ac2e17f2f363cfa2099d7972be37
3
+ metadata.gz: c82b12d0de833f9acac8900b657d0c7b53a46937
4
+ data.tar.gz: 2bed7bc3ac9546910ed7f0f86a98a99a5cebda1f
5
5
  SHA512:
6
- metadata.gz: 16c7a7fa838785268fcb6c4a904019b61cade772c83e6434b3b19506ee96276ba418a0b15e3fb40455f304eac5d4bb115e3b488293f48fce1fd33884e17fa88d
7
- data.tar.gz: d11a7acc1db319ca488b5a55a690348e8df19779e96209863a85764e3ab55b689efd0ca3dc54687935064ff0eb3c0c8659867020a0ee1e0d56ba19ad49467e16
6
+ metadata.gz: 9501e8dc97d619b77798b8d1f43e6f0b88ae41f1d4bf512e52792642818fef019239b70c965e6df5da13a02afac43d21a91deaf8aa26dabab9778135ac2bc4fc
7
+ data.tar.gz: ae2b556f17c9c50846c85bb0e6cd8a0d23cb9bc1727e2359832b2f1506498acc2a2b1242d1f67b25534d39e85f466b4a0a61a3d4c7aede7cf0119284311b4bc4
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # README
2
2
 
3
+ NOTE: This gem is merged into groonga-client gem. Use groonga-client
4
+ instead of this.
5
+
3
6
  ## Name
4
7
 
5
8
  groonga-client-cli
@@ -1,5 +1,11 @@
1
1
  # NEWS
2
2
 
3
+ ## 1.0.4 - 2016-12-20
4
+
5
+ ### Improvements
6
+
7
+ * Merged into groonga-client gem.
8
+
3
9
  ## 1.0.3 - 2016-08-19
4
10
 
5
11
  ### Improvements
@@ -52,12 +52,8 @@ Gem::Specification.new do |spec|
52
52
  spec.files += [".yardopts"]
53
53
  spec.files += Dir.glob("lib/**/*.rb")
54
54
  spec.files += Dir.glob("doc/text/*")
55
- Dir.chdir("bin") do
56
- spec.executables = Dir.glob("*")
57
- end
58
55
 
59
- spec.add_runtime_dependency("groonga-client", ">= 0.1.6")
60
- spec.add_runtime_dependency("groonga-command-parser")
56
+ spec.add_runtime_dependency("groonga-client", ">= 0.3.6")
61
57
 
62
58
  spec.add_development_dependency("bundler")
63
59
  spec.add_development_dependency("rake")
@@ -15,5 +15,5 @@
15
15
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
  module GroongaClientCLI
18
- VERSION = "1.0.3"
18
+ VERSION = "1.0.5"
19
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groonga-client-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-19 00:00:00.000000000 Z
11
+ date: 2016-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: groonga-client
@@ -16,28 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.6
19
+ version: 0.3.6
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.6
27
- - !ruby/object:Gem::Dependency
28
- name: groonga-command-parser
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
26
+ version: 0.3.6
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -98,8 +84,7 @@ description: Groonga command line clients can work without Groonga. `groonga` co
98
84
  provided by Groonga can only use for GQTP but they can use for both GQTP and HTTP.
99
85
  email:
100
86
  - kou@clear-code.com
101
- executables:
102
- - groonga-client
87
+ executables: []
103
88
  extensions: []
104
89
  extra_rdoc_files: []
105
90
  files:
@@ -107,11 +92,9 @@ files:
107
92
  - Gemfile
108
93
  - README.md
109
94
  - Rakefile
110
- - bin/groonga-client
111
95
  - doc/text/lgpl-2.1.txt
112
96
  - doc/text/news.md
113
97
  - groonga-client-cli.gemspec
114
- - lib/groonga-client-cli/groonga-client.rb
115
98
  - lib/groonga-client-cli/version.rb
116
99
  homepage: https://github.com/ranguba/groonga-client-cli
117
100
  licenses:
@@ -133,9 +116,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
116
  version: '0'
134
117
  requirements: []
135
118
  rubyforge_project:
136
- rubygems_version: 2.5.1
119
+ rubygems_version: 2.5.2
137
120
  signing_key:
138
121
  specification_version: 4
139
122
  summary: Groonga-client-cli provides command line Groonga clients.
140
123
  test_files: []
141
- has_rdoc:
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # -*- mode: ruby -*-
3
- #
4
- # Copyright (C) 2015 Kouhei Sutou <kou@clear-code.com>
5
- #
6
- # This library is free software; you can redistribute it and/or
7
- # modify it under the terms of the GNU Lesser General Public
8
- # License as published by the Free Software Foundation; either
9
- # version 2.1 of the License, or (at your option) any later version.
10
- #
11
- # This library is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
- # Lesser General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU Lesser General Public
17
- # License along with this library; if not, write to the Free Software
18
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
-
20
- require "groonga-client-cli/groonga-client"
21
-
22
- client = GroongaClientCLI::GroongaClient.new
23
- exit(client.run(ARGV))
@@ -1,233 +0,0 @@
1
- # Copyright (C) 2015-2016 Kouhei Sutou <kou@clear-code.com>
2
- #
3
- # This library is free software; you can redistribute it and/or
4
- # modify it under the terms of the GNU Lesser General Public
5
- # License as published by the Free Software Foundation; either
6
- # version 2.1 of the License, or (at your option) any later version.
7
- #
8
- # This library is distributed in the hope that it will be useful,
9
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
- # Lesser General Public License for more details.
12
- #
13
- # You should have received a copy of the GNU Lesser General Public
14
- # License along with this library; if not, write to the Free Software
15
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
-
17
- require "ostruct"
18
- require "optparse"
19
- require "json"
20
- require "securerandom"
21
-
22
- require "groonga/command/parser"
23
-
24
- require "groonga/client"
25
-
26
- require "groonga-client-cli/version"
27
-
28
- module GroongaClientCLI
29
- class GroongaClient
30
- def initialize
31
- @protocol = :http
32
- @host = "localhost"
33
- @port = nil
34
-
35
- @read_timeout = Groonga::Client::Default::READ_TIMEOUT
36
-
37
- @chunk = false
38
-
39
- @runner_options = {
40
- :split_load_chunk_size => 10000,
41
- :generate_request_id => false,
42
- }
43
- end
44
-
45
- def run(argv)
46
- command_file_paths = parse_command_line(argv)
47
-
48
- @client = Groonga::Client.new(:protocol => @protocol,
49
- :host => @host,
50
- :port => @port,
51
- :read_timeout => @read_timeout,
52
- :chunk => @chunk,
53
- :backend => :synchronous)
54
- runner = Runner.new(@client, @runner_options)
55
-
56
- if command_file_paths.empty?
57
- $stdin.each_line do |line|
58
- runner << line
59
- end
60
- else
61
- command_file_paths.each do |command_file_path|
62
- File.open(command_file_path) do |command_file|
63
- last_line = nil
64
- command_file.each_line do |line|
65
- last_line = line
66
- runner << line
67
- end
68
- if last_line and !last_line.end_with?("\n")
69
- runner << "\n"
70
- end
71
- end
72
- end
73
- end
74
- runner.finish
75
-
76
- true
77
- end
78
-
79
- private
80
- def parse_command_line(argv)
81
- parser = OptionParser.new
82
- parser.version = VERSION
83
- parser.banner += " GROONGA_COMMAND_FILE1 GROONGA_COMMAND_FILE2 ..."
84
-
85
- parser.separator("")
86
-
87
- parser.separator("Connection:")
88
-
89
- available_protocols = [:http, :gqtp]
90
- parser.on("--protocol=PROTOCOL", [:http, :gqtp],
91
- "Protocol to connect to Groonga server.",
92
- "[#{available_protocols.join(", ")}]",
93
- "(#{@protocol})") do |protocol|
94
- @protocol = protocol
95
- end
96
-
97
- parser.on("--host=HOST",
98
- "Groonga server to be connected.",
99
- "(#{@host})") do |host|
100
- @host = host
101
- end
102
-
103
- parser.on("--port=PORT", Integer,
104
- "Port number of Groonga server to be connected.",
105
- "(auto)") do |port|
106
- @port = port
107
- end
108
-
109
- parser.on("--read-timeout=TIMEOUT", Integer,
110
- "Timeout on reading response from Groonga server.",
111
- "You can disable timeout by specifying -1.",
112
- "(#{@read_timeout})") do |timeout|
113
- @read_timeout = timeout
114
- end
115
-
116
- parser.on("--split-load-chunk-size=SIZE", Integer,
117
- "Split a large load to small loads.",
118
- "Each small load has at most SIZE records.",
119
- "Set 0 to SIZE to disable this feature.",
120
- "(#{@runner_options[:split_load_chunk_size]})") do |size|
121
- @runner_options[:split_load_chunk_size] = size
122
- end
123
-
124
- parser.on("--[no-]generate-request-id",
125
- "Add auto generated request ID to all commands.",
126
- "(#{@runner_options[:generate_request_id]})") do |boolean|
127
- @runner_options[:generate_request_id] = boolean
128
- end
129
-
130
- parser.on("--[no-]chunk",
131
- "Use \"Transfer-Encoding: chunked\" for load command.",
132
- "HTTP only.",
133
- "(#{@chunk})") do |boolean|
134
- @chunk = boolean
135
- end
136
-
137
- command_file_paths = parser.parse(argv)
138
-
139
- @port ||= default_port(@protocol)
140
-
141
- command_file_paths
142
- end
143
-
144
- def default_port(protocol)
145
- case protocol
146
- when :http
147
- 10041
148
- when :gqtp
149
- 10043
150
- end
151
- end
152
-
153
- class Runner
154
- def initialize(client, options={})
155
- @client = client
156
- @split_load_chunk_size = options[:split_load_chunk_size] || 10000
157
- @generate_request_id = options[:generate_request_id]
158
- @load_values = []
159
- @parser = create_command_parser
160
- end
161
-
162
- def <<(line)
163
- @parser << line
164
- end
165
-
166
- def finish
167
- @parser.finish
168
- end
169
-
170
- private
171
- def create_command_parser
172
- parser = Groonga::Command::Parser.new
173
-
174
- parser.on_command do |command|
175
- run_command(command)
176
- end
177
-
178
- parser.on_load_columns do |command, columns|
179
- command[:columns] ||= columns.join(",")
180
- end
181
-
182
- parser.on_load_value do |command, value|
183
- unless command[:values]
184
- @load_values << value
185
- if @load_values.size == @split_load_chunk_size
186
- consume_load_values(command)
187
- end
188
- end
189
- command.original_source.clear
190
- end
191
-
192
- parser.on_load_complete do |command|
193
- if command[:values]
194
- run_command(client, command)
195
- else
196
- consume_load_values(command)
197
- end
198
- end
199
-
200
- parser
201
- end
202
-
203
- def consume_load_values(load_command)
204
- return if @load_values.empty?
205
-
206
- values_json = "["
207
- @load_values.each_with_index do |value, i|
208
- values_json << "," unless i.zero?
209
- values_json << "\n"
210
- values_json << JSON.generate(value)
211
- end
212
- values_json << "\n]\n"
213
- load_command[:values] = values_json
214
- run_command(load_command)
215
- @load_values.clear
216
- load_command[:values] = nil
217
- end
218
-
219
- def run_command(command)
220
- command[:request_id] ||= SecureRandom.uuid if @generate_request_id
221
- response = @client.execute(command)
222
- case command.output_type
223
- when :json
224
- puts(JSON.pretty_generate([response.header, response.body]))
225
- when :xml
226
- puts(response.raw)
227
- else
228
- puts(response.body)
229
- end
230
- end
231
- end
232
- end
233
- end