groonga-command-parser 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6586a6d72a155715ad67c47652183969cf9a5255
4
+ data.tar.gz: a3879393e9c3d9f09718c8f253b2cdc86be05119
5
+ SHA512:
6
+ metadata.gz: 7354d617dd59ffba8f795c914b73a439eee43a03916a6eea2bd7843aa02fcdaaa53c0a57dc756f308a49e77f1a90e1bd29c171c463bf2ca8972447738d1509ba
7
+ data.tar.gz: 9abeebb9d08f1af5866533f0599e7e09bde3ca2be723716863822d7a2a36a80db6f0f2832ecb183210456fb4f1e650a4350e07e5797732f7ab1b313fbec00913
@@ -1,5 +1,11 @@
1
1
  # News
2
2
 
3
+ ## 1.0.2: 2014-10-02
4
+
5
+ ### Improvements
6
+
7
+ * Supported custom prefix URI such as `/groonga/db/select?table=Users`.
8
+
3
9
  ## 1.0.1: 2013-10-29
4
10
 
5
11
  ### Improvements
@@ -1,6 +1,6 @@
1
1
  # -*- mode: ruby; coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2012-2013 Kouhei Sutou <kou@clear-code.com>
3
+ # Copyright (C) 2012-2014 Kouhei Sutou <kou@clear-code.com>
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the GNU Lesser General Public
@@ -52,7 +52,7 @@ Gem::Specification.new do |spec|
52
52
  spec.licenses = ["LGPLv2.1+"]
53
53
  spec.require_paths = ["lib"]
54
54
 
55
- spec.add_runtime_dependency("groonga-command")
55
+ spec.add_runtime_dependency("groonga-command", ">= 1.0.9")
56
56
  spec.add_runtime_dependency("yajl-ruby")
57
57
 
58
58
  spec.add_development_dependency("test-unit")
@@ -16,6 +16,7 @@
16
16
  # License along with this library; if not, write to the Free Software
17
17
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
 
19
+ require "English"
19
20
  require "shellwords"
20
21
  require "cgi"
21
22
 
@@ -342,15 +343,15 @@ module Groonga
342
343
  end
343
344
 
344
345
  def parse_command(input)
345
- if input.start_with?("/d/")
346
+ if input.start_with?("/")
346
347
  parse_uri_path(input)
347
348
  else
348
349
  parse_command_line(input)
349
350
  end
350
351
  end
351
352
 
352
- def parse_uri_path(path)
353
- name, arguments_string = path.split(/\?/, 2)
353
+ def parse_uri_path(relative_uri)
354
+ path, arguments_string = relative_uri.split(/\?/, 2)
354
355
  arguments = {}
355
356
  if arguments_string
356
357
  arguments_string.split(/&/).each do |argument_string|
@@ -359,12 +360,19 @@ module Groonga
359
360
  arguments[key] = CGI.unescape(value)
360
361
  end
361
362
  end
362
- name = name.gsub(/\A\/d\//, '')
363
+ if /\/([^\/]*)\z/=~ path
364
+ prefix = $PREMATCH
365
+ name = $1
366
+ else
367
+ prefix = ""
368
+ name = path
369
+ end
363
370
  name, output_type = name.split(/\./, 2)
364
371
  arguments["output_type"] = output_type if output_type
365
372
  command_class = Command.find(name)
366
373
  command = command_class.new(name, arguments)
367
374
  command.original_format = :uri
375
+ command.path_prefix = prefix
368
376
  command
369
377
  end
370
378
 
@@ -19,7 +19,7 @@
19
19
  module Groonga
20
20
  module Command
21
21
  class Parser
22
- VERSION = "1.0.1"
22
+ VERSION = "1.0.2"
23
23
  end
24
24
  end
25
25
  end
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2011-2013 Kouhei Sutou <kou@clear-code.com>
3
+ # Copyright (C) 2011-2014 Kouhei Sutou <kou@clear-code.com>
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the GNU Lesser General Public
@@ -49,6 +49,18 @@ class ParserTest < Test::Unit::TestCase
49
49
  assert_equal({:table => "Users"}, command.arguments)
50
50
  end
51
51
 
52
+ def test_custom_prefix
53
+ path = "/db1/select?table=Users"
54
+ command = Groonga::Command::Parser.parse(path)
55
+ assert_equal("/db1", command.path_prefix)
56
+ end
57
+
58
+ def test_deep_custom_prefix
59
+ path = "/groonga/db1/select?table=Users"
60
+ command = Groonga::Command::Parser.parse(path)
61
+ assert_equal("/groonga/db1", command.path_prefix)
62
+ end
63
+
52
64
  class ParseTest < self
53
65
  include ParseTests
54
66
  end
metadata CHANGED
@@ -1,158 +1,139 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groonga-command-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
5
- prerelease:
4
+ version: 1.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Kouhei Sutou
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-10-29 00:00:00.000000000 Z
11
+ date: 2014-10-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: groonga-command
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: 1.0.9
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: '0'
26
+ version: 1.0.9
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: yajl-ruby
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: test-unit
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: test-unit-notify
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rake
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: bundler
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - ">="
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - ">="
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: packnga
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - ">="
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - ">="
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: yard
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - ">="
132
116
  - !ruby/object:Gem::Version
133
117
  version: '0'
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - ">="
140
123
  - !ruby/object:Gem::Version
141
124
  version: '0'
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: redcarpet
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
- - - ! '>='
129
+ - - ">="
148
130
  - !ruby/object:Gem::Version
149
131
  version: '0'
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
- - - ! '>='
136
+ - - ">="
156
137
  - !ruby/object:Gem::Version
157
138
  version: '0'
158
139
  description: ''
@@ -162,47 +143,46 @@ executables: []
162
143
  extensions: []
163
144
  extra_rdoc_files: []
164
145
  files:
146
+ - ".yardopts"
147
+ - Gemfile
165
148
  - README.md
166
149
  - Rakefile
167
- - Gemfile
150
+ - doc/text/lgpl-2.1.txt
151
+ - doc/text/news.md
168
152
  - groonga-command-parser.gemspec
169
- - .yardopts
170
153
  - lib/groonga/command/parser.rb
171
154
  - lib/groonga/command/parser/error.rb
172
155
  - lib/groonga/command/parser/version.rb
173
- - doc/text/news.md
174
- - doc/text/lgpl-2.1.txt
156
+ - test/groonga-command-parser-test-utils.rb
175
157
  - test/run-test.rb
176
158
  - test/test-parser.rb
177
- - test/groonga-command-parser-test-utils.rb
178
159
  homepage: https://github.com/groonga/groonga-command-parser
179
160
  licenses:
180
161
  - LGPLv2.1+
162
+ metadata: {}
181
163
  post_install_message:
182
164
  rdoc_options: []
183
165
  require_paths:
184
166
  - lib
185
167
  required_ruby_version: !ruby/object:Gem::Requirement
186
- none: false
187
168
  requirements:
188
- - - ! '>='
169
+ - - ">="
189
170
  - !ruby/object:Gem::Version
190
171
  version: '0'
191
172
  required_rubygems_version: !ruby/object:Gem::Requirement
192
- none: false
193
173
  requirements:
194
- - - ! '>='
174
+ - - ">="
195
175
  - !ruby/object:Gem::Version
196
176
  version: '0'
197
177
  requirements: []
198
178
  rubyforge_project:
199
- rubygems_version: 1.8.23
179
+ rubygems_version: 2.2.2
200
180
  signing_key:
201
- specification_version: 3
181
+ specification_version: 4
202
182
  summary: Groonga-command-parser is a Ruby library to parses [groonga](http://groonga.org/)'s
203
183
  command syntax. You can write a program to process groonga's command by using groonga-command-parser.
204
184
  test_files:
185
+ - test/groonga-command-parser-test-utils.rb
205
186
  - test/run-test.rb
206
187
  - test/test-parser.rb
207
- - test/groonga-command-parser-test-utils.rb
208
188
  has_rdoc: