groonga-command 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/doc/text/news.md +6 -0
- data/lib/groonga/command/base.rb +4 -3
- data/lib/groonga/command/format/command.rb +9 -7
- data/lib/groonga/command/select.rb +3 -0
- data/lib/groonga/command/version.rb +1 -1
- data/test/command/test-base.rb +15 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d4468aae3fdfadaab5cbe95c1e3605bc63ee415
|
4
|
+
data.tar.gz: 2314bcb34ab6bf0a616d9ab62b471d20a4df2505
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51145199df5284fc194db4d9041dfda31a8a1fa3cd1000b72f04a2f5d2c1f49392e0eb5a376b2fb425956c8288cc8b76c6fd6eb257d4fa1bdb54cf4cbd9e0cfa
|
7
|
+
data.tar.gz: 9eccabfcd2fe3817695f9dba33822f6584e52fd5fb4b6854a6cafcea803047991b10d4c3d551152f093bd0a8b37e60588f7b0dcb1f0042962c35f79dbfc91e3b
|
data/doc/text/news.md
CHANGED
data/lib/groonga/command/base.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2012-
|
1
|
+
# Copyright (C) 2012-2017 Kouhei Sutou <kou@clear-code.com>
|
2
2
|
#
|
3
3
|
# This library is free software; you can redistribute it and/or
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -148,8 +148,9 @@ module Groonga
|
|
148
148
|
Format::URI.new(@path_prefix, @command_name, normalized_arguments).path
|
149
149
|
end
|
150
150
|
|
151
|
-
def to_command_format
|
152
|
-
Format::Command.new(@command_name, normalized_arguments)
|
151
|
+
def to_command_format(options={})
|
152
|
+
format = Format::Command.new(@command_name, normalized_arguments)
|
153
|
+
format.command_line(options)
|
153
154
|
end
|
154
155
|
|
155
156
|
private
|
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Copyright (C) 2012-2013 Kouhei Sutou <kou@clear-code.com>
|
1
|
+
# Copyright (C) 2012-2017 Kouhei Sutou <kou@clear-code.com>
|
4
2
|
#
|
5
3
|
# This library is free software; you can redistribute it and/or
|
6
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -42,16 +40,20 @@ module Groonga
|
|
42
40
|
@arguments = arguments
|
43
41
|
end
|
44
42
|
|
45
|
-
def command_line
|
43
|
+
def command_line(options={})
|
44
|
+
pretty_print = options[:pretty_print]
|
46
45
|
components = [@name]
|
47
46
|
sorted_arguments = @arguments.sort_by do |name, _|
|
48
47
|
name.to_s
|
49
48
|
end
|
50
49
|
sorted_arguments.each do |name, value|
|
51
|
-
components << "--#{name}"
|
52
|
-
|
50
|
+
components << "--#{name} #{self.class.escape_value(value)}"
|
51
|
+
end
|
52
|
+
if pretty_print
|
53
|
+
components.join(" \\\n ")
|
54
|
+
else
|
55
|
+
components.join(" ")
|
53
56
|
end
|
54
|
-
components.join(" ")
|
55
57
|
end
|
56
58
|
end
|
57
59
|
end
|
data/test/command/test-base.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Copyright (C) 2011-2014 Kouhei Sutou <kou@clear-code.com>
|
1
|
+
# Copyright (C) 2011-2017 Kouhei Sutou <kou@clear-code.com>
|
4
2
|
#
|
5
3
|
# This library is free software; you can redistribute it and/or
|
6
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -108,6 +106,20 @@ class BaseCommandTest < Test::Unit::TestCase
|
|
108
106
|
assert_equal("select --output_type \"json\" --table \"Users\"",
|
109
107
|
select.to_command_format)
|
110
108
|
end
|
109
|
+
|
110
|
+
def test_pretty_print
|
111
|
+
select = Groonga::Command::Base.new("select",
|
112
|
+
:table => "Users",
|
113
|
+
:filter => "_key == 29",
|
114
|
+
:output_type => "json")
|
115
|
+
command = select.to_command_format(:pretty_print => true)
|
116
|
+
assert_equal(<<-COMMAND.chomp, command)
|
117
|
+
select \\
|
118
|
+
--filter "_key == 29" \\
|
119
|
+
--output_type "json" \\
|
120
|
+
--table "Users"
|
121
|
+
COMMAND
|
122
|
+
end
|
111
123
|
end
|
112
124
|
|
113
125
|
sub_test_case("#[]") do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: groonga-command
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|