groonga-command 1.3.1 → 1.3.2

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: 825e111ecaa00e1ab59e8d94d960c7d0c74ed1c5
4
- data.tar.gz: 8cd981a313f1ff936e55f381b34103cf07bf6d7f
3
+ metadata.gz: 3d4468aae3fdfadaab5cbe95c1e3605bc63ee415
4
+ data.tar.gz: 2314bcb34ab6bf0a616d9ab62b471d20a4df2505
5
5
  SHA512:
6
- metadata.gz: aa021d38662c0d566a6ef81beb5eda9167cbae3b51372f394266ce54636a432bc371166d6239c1a37e4398564352c6b6fe8b9eade91e70fd61f96a2697edf250
7
- data.tar.gz: 1a95dfb5a3edbe0153e91d8620724ae09cb75ddced9dac0ff24480d288642bc1d6f5ae8e94524cf6e58ba45400ce8fa56056aa1cac22f077130517e05427cbab
6
+ metadata.gz: 51145199df5284fc194db4d9041dfda31a8a1fa3cd1000b72f04a2f5d2c1f49392e0eb5a376b2fb425956c8288cc8b76c6fd6eb257d4fa1bdb54cf4cbd9e0cfa
7
+ data.tar.gz: 9eccabfcd2fe3817695f9dba33822f6584e52fd5fb4b6854a6cafcea803047991b10d4c3d551152f093bd0a8b37e60588f7b0dcb1f0042962c35f79dbfc91e3b
data/doc/text/news.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # News
2
2
 
3
+ ## 1.3.2: 2017-01-18
4
+
5
+ ### Improvements
6
+
7
+ * {Groonga::Command::Format::Command}: Supported pretty print.
8
+
3
9
  ## 1.3.1: 2016-12-08
4
10
 
5
11
  ### Improvements
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012-2016 Kouhei Sutou <kou@clear-code.com>
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).command_line
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
- # -*- coding: utf-8 -*-
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
- components << self.class.escape_value(value)
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
@@ -114,6 +114,9 @@ module Groonga
114
114
  @slices ||= parse_slices
115
115
  end
116
116
 
117
+ # TODO: We should return `::Array` instead of raw
118
+ # `output_columns` value. But it breaks backward
119
+ # compatibility...
117
120
  def output_columns
118
121
  self[:output_columns]
119
122
  end
@@ -16,6 +16,6 @@
16
16
 
17
17
  module Groonga
18
18
  module Command
19
- VERSION = "1.3.1"
19
+ VERSION = "1.3.2"
20
20
  end
21
21
  end
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
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.1
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: 2016-12-08 00:00:00.000000000 Z
11
+ date: 2017-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json