sdbcli 1.4.2 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -92,7 +92,7 @@ https://bitbucket.org/winebarrel/sdbcli
92
92
  displays a present page number or displays a result of the specified page
93
93
  (PAGE statement is published after SELECT statement)
94
94
 
95
- DESC domain_name
95
+ DESC[RIBE] domain_name
96
96
  displays information about the domain
97
97
 
98
98
  USE region_or_endpoint
@@ -188,3 +188,35 @@ If '-' is specified as a file name, the input/output of data will become a stand
188
188
  # 6 rows in set
189
189
 
190
190
  'sum' method and 'avg' method are added to Array class.
191
+
192
+ == Group By (Aggregate)
193
+
194
+ ap-northeast-1> select * from access_logs limit 30;
195
+ ---
196
+ - [20130205/host1, {host: host1, response_time: "298.37"}]
197
+ - [20130205/host2, {host: host2, response_time: "294.65"}]
198
+ - [20130205/host3, {host: host3, response_time: "293.42"}]
199
+ - [20130205/host4, {host: host4, response_time: "294.08"}]
200
+ - [20130205/host5, {host: host5, response_time: "294.3"}]
201
+ ...
202
+ # 30 rows in set
203
+
204
+ ap-northeast-1> select * from access_logs limit 30 | group_by(:host) {|i| i.response_time.to_f.avg };
205
+ ---
206
+ host1: 303.6425
207
+ host2: 301.8875
208
+ host3: 300.9525
209
+ host4: 302.1675
210
+ host5: 301.62
211
+
212
+ == Exec ruby or shell command
213
+
214
+ ap-northeast-1> | (1 + 1).to_f;
215
+ --- 2.0
216
+
217
+ ap-northeast-1> ! ls;
218
+ --- |
219
+ README
220
+ bin
221
+ lib
222
+ sdbcli.gemspec
data/bin/sdbcli CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
3
3
 
4
- Version = '1.4.2'
4
+ Version = '1.4.3'
5
5
  HISTORY_FILE = File.join((ENV['HOME'] || ENV['USERPROFILE'] || '.'), '.sdbcli_history')
6
6
  HISTSIZE = 500
7
7
  SELECT_LIMIT = 2500
@@ -406,7 +406,7 @@ PAGE [number]
406
406
  displays a present page number or displays a result of the specified page
407
407
  (PAGE statement is published after SELECT statement)
408
408
 
409
- DESC domain_name
409
+ DESC[RIBE] domain_name
410
410
  displays information about the domain
411
411
 
412
412
  USE region_or_endpoint
@@ -13,7 +13,7 @@ module SimpleDB
13
13
 
14
14
  class Parser < Racc::Parser
15
15
 
16
- module_eval(<<'...end sdb-parser.y/module_eval...', 'sdb-parser.y', 282)
16
+ module_eval(<<'...end sdb-parser.y/module_eval...', 'sdb-parser.y', 294)
17
17
 
18
18
  KEYWORDS = %w(
19
19
  ADD
@@ -110,6 +110,10 @@ def scan
110
110
  yield [tok, tok]
111
111
  elsif (tok = @ss.scan /[a-z_$][-0-9a-z_$.]*\b/i)
112
112
  yield [:IDENTIFIER, tok]
113
+ elsif (tok = @ss.scan /\|/i)
114
+ yield [:RUBY, @ss.scan(/.*/)]
115
+ elsif (tok = @ss.scan /!/i)
116
+ yield [:EXEC, @ss.scan(/.*/)]
113
117
  else
114
118
  raise Racc::ParseError, ('parse error on value "%s"' % @ss.rest.inspect)
115
119
  end
@@ -139,145 +143,151 @@ end
139
143
  ##### State transition tables begin ###
140
144
 
141
145
  racc_action_table = [
142
- 17, 10, 75, 72, 18, 71, 37, 70, 73, 73,
143
- 35, 71, 33, 70, 19, 83, 84, 20, 83, 84,
144
- 21, 22, 23, 24, 25, 26, 58, 27, 28, 29,
145
- 44, 45, 30, 31, 32, 83, 84, 83, 84, 103,
146
- 104, 83, 84, 108, 104, 83, 84, 79, 80, 53,
147
- 54, 83, 84, 83, 84, 65, 66, 59, 60, 63,
148
- 63, 56, 67, 51, 55, 74, 57, 76, 77, 78,
149
- 52, 81, 63, 51, 86, 87, 88, 89, 50, 91,
150
- 92, 93, 49, 95, 48, 47, 46, 43, 102, 42,
151
- 105, 37, 39, 38 ]
146
+ 7, 11, 78, 79, 20, 72, 45, 74, 77, 77,
147
+ 42, 72, 61, 74, 18, 86, 87, 26, 86, 87,
148
+ 34, 2, 6, 10, 14, 17, 62, 22, 25, 29,
149
+ 86, 87, 1, 5, 9, 13, 16, 86, 87, 49,
150
+ 50, 86, 87, 86, 87, 82, 83, 107, 108, 86,
151
+ 87, 69, 70, 86, 87, 59, 60, 112, 108, 63,
152
+ 64, 65, 65, 56, 58, 75, 57, 56, 55, 80,
153
+ 81, 54, 84, 53, 65, 89, 90, 91, 92, 45,
154
+ 94, 95, 96, 97, 98, 48, 47, 46, 41, 40,
155
+ 106, 39, 109, 38, 37, 76 ]
152
156
 
153
157
  racc_action_check = [
154
- 0, 0, 64, 61, 0, 60, 18, 60, 64, 61,
155
- 18, 80, 1, 80, 0, 91, 91, 0, 95, 95,
156
- 0, 0, 0, 0, 0, 0, 50, 0, 0, 0,
157
- 29, 29, 0, 0, 0, 93, 93, 92, 92, 100,
158
- 100, 88, 88, 107, 107, 74, 74, 68, 68, 39,
159
- 39, 104, 104, 105, 105, 55, 55, 51, 52, 53,
160
- 54, 42, 58, 41, 40, 63, 43, 65, 66, 67,
161
- 38, 72, 73, 36, 75, 76, 78, 79, 34, 81,
162
- 86, 87, 33, 89, 32, 31, 30, 28, 96, 26,
163
- 102, 21, 20, 19 ]
158
+ 0, 0, 66, 68, 0, 83, 20, 83, 66, 68,
159
+ 20, 62, 52, 62, 0, 94, 94, 0, 96, 96,
160
+ 0, 0, 0, 0, 0, 0, 54, 0, 0, 0,
161
+ 95, 95, 0, 0, 0, 0, 0, 97, 97, 29,
162
+ 29, 98, 98, 76, 76, 71, 71, 105, 105, 108,
163
+ 108, 61, 61, 109, 109, 48, 48, 111, 111, 55,
164
+ 56, 59, 60, 51, 47, 63, 46, 44, 43, 69,
165
+ 70, 41, 75, 40, 77, 78, 79, 80, 82, 34,
166
+ 84, 89, 90, 91, 92, 26, 25, 24, 18, 17,
167
+ 99, 9, 106, 5, 1, 65 ]
164
168
 
165
169
  racc_action_pointer = [
166
- -1, 12, nil, nil, nil, nil, nil, nil, nil, nil,
167
- nil, nil, nil, nil, nil, nil, nil, nil, -1, 77,
168
- 85, 84, nil, nil, nil, nil, 62, nil, 60, -1,
169
- 79, 78, 77, 82, 72, nil, 59, nil, 63, 30,
170
- 58, 49, 54, 59, nil, nil, nil, nil, nil, nil,
171
- 19, 50, 46, 52, 53, 48, nil, nil, 54, nil,
172
- -2, -5, nil, 55, -6, 59, 59, 60, 34, nil,
173
- nil, nil, 62, 65, 42, 65, 66, nil, 66, 60,
174
- 4, 69, nil, nil, nil, nil, 70, 71, 38, 71,
175
- nil, 12, 34, 32, nil, 15, 74, nil, nil, nil,
176
- 26, nil, 78, nil, 48, 50, nil, 30, nil ]
170
+ -1, 87, nil, nil, nil, 86, nil, nil, nil, 84,
171
+ nil, nil, nil, nil, nil, nil, nil, 62, 72, nil,
172
+ -1, nil, nil, nil, 87, 59, 78, nil, nil, 8,
173
+ nil, nil, nil, nil, 72, nil, nil, nil, nil, nil,
174
+ 66, 64, nil, 62, 53, nil, 66, 57, 36, nil,
175
+ nil, 49, 6, nil, 14, 52, 53, nil, nil, 54,
176
+ 55, 44, 4, 57, nil, 85, -6, nil, -5, 61,
177
+ 61, 32, nil, nil, nil, 63, 40, 67, 66, 67,
178
+ 68, nil, 61, -2, 70, nil, nil, nil, nil, 71,
179
+ 72, 73, 72, nil, 12, 27, 15, 34, 38, 76,
180
+ nil, nil, nil, nil, nil, 34, 80, nil, 46, 50,
181
+ nil, 44, nil ]
177
182
 
178
183
  racc_action_default = [
179
- -63, -63, -1, -2, -3, -4, -5, -6, -7, -8,
180
- -9, -10, -11, -12, -13, -14, -15, -16, -20, -63,
181
- -63, -45, -47, -48, -49, -50, -63, -52, -63, -63,
182
- -63, -63, -63, -63, -63, -21, -22, -59, -63, -63,
183
- -63, -46, -63, -63, -54, -55, -56, -57, -58, 109,
184
- -63, -63, -63, -63, -63, -63, -51, -53, -63, -60,
185
- -63, -31, -38, -63, -35, -42, -43, -63, -63, -26,
186
- -28, -29, -32, -63, -63, -36, -63, -44, -63, -63,
187
- -63, -33, -39, -17, -18, -40, -37, -63, -63, -63,
188
- -27, -63, -63, -63, -19, -63, -25, -30, -34, -41,
189
- -63, -61, -63, -23, -63, -63, -62, -63, -24 ]
184
+ -67, -67, -49, -17, -5, -67, -50, -18, -6, -67,
185
+ -51, -9, -7, -61, -52, -8, -62, -67, -67, -10,
186
+ -22, -11, -54, -12, -67, -67, -67, -13, -1, -67,
187
+ -14, -2, -15, -3, -47, -16, -4, -58, -59, -60,
188
+ -67, -67, -23, -67, -24, -63, -67, -67, -67, -56,
189
+ -57, -48, -67, -53, -67, -67, -67, 113, -55, -67,
190
+ -67, -67, -67, -67, -64, -67, -33, -40, -37, -44,
191
+ -45, -67, -31, -28, -30, -67, -67, -67, -34, -38,
192
+ -67, -46, -67, -67, -67, -42, -19, -20, -41, -35,
193
+ -39, -67, -67, -29, -67, -67, -67, -67, -67, -27,
194
+ -21, -32, -36, -43, -65, -67, -67, -25, -67, -67,
195
+ -66, -67, -26 ]
190
196
 
191
197
  racc_goto_table = [
192
- 85, 69, 100, 36, 61, 64, 41, 14, 7, 8,
193
- 9, 11, 107, 12, 94, 13, 6, 97, 98, 99,
194
- 15, 90, 16, 1, 34, 5, 96, 4, 68, 3,
195
- 106, 2, 82, 40 ]
198
+ 85, 73, 44, 105, 66, 68, 30, 8, 12, 15,
199
+ 19, 21, 23, 27, 111, 4, 51, 32, 100, 101,
200
+ 102, 103, 93, 35, 3, 24, 43, 36, 99, 33,
201
+ 71, 31, 110, 28, 88, 52 ]
196
202
 
197
203
  racc_goto_check = [
198
- 16, 22, 20, 18, 23, 23, 18, 13, 7, 8,
199
- 9, 10, 20, 11, 16, 12, 6, 16, 16, 16,
200
- 14, 22, 15, 1, 17, 5, 19, 4, 21, 3,
201
- 16, 2, 24, 25 ]
204
+ 18, 24, 20, 22, 25, 25, 14, 7, 8, 9,
205
+ 10, 11, 12, 13, 22, 6, 20, 15, 18, 18,
206
+ 18, 18, 24, 16, 17, 1, 19, 5, 21, 4,
207
+ 23, 3, 18, 2, 26, 27 ]
202
208
 
203
209
  racc_goto_pointer = [
204
- nil, 23, 31, 29, 27, 25, 16, 8, 9, 10,
205
- 11, 13, 15, 7, 20, 22, -74, 6, -15, -63,
206
- -93, -32, -59, -49, -41, 12 ]
210
+ nil, 25, 33, 31, 29, 27, 15, 7, 8, 9,
211
+ 10, 11, 12, 13, 6, 17, 23, 24, -76, 6,
212
+ -18, -64, -95, -32, -61, -55, -43, 1 ]
207
213
 
208
214
  racc_goto_default = [
209
215
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
210
- nil, nil, nil, nil, nil, nil, 101, nil, nil, nil,
211
- nil, nil, nil, nil, 62, nil ]
216
+ nil, nil, nil, nil, nil, nil, nil, nil, 104, nil,
217
+ nil, nil, nil, nil, nil, nil, 67, nil ]
212
218
 
213
219
  racc_reduce_table = [
214
220
  0, 0, :racc_error,
215
- 1, 37, :_reduce_none,
216
- 1, 37, :_reduce_none,
217
- 1, 37, :_reduce_none,
218
- 1, 37, :_reduce_none,
219
- 1, 37, :_reduce_none,
220
- 1, 37, :_reduce_none,
221
- 1, 37, :_reduce_none,
222
- 1, 37, :_reduce_none,
223
- 1, 37, :_reduce_none,
224
- 1, 37, :_reduce_none,
225
- 1, 37, :_reduce_none,
226
- 1, 37, :_reduce_none,
227
- 1, 37, :_reduce_none,
228
- 1, 37, :_reduce_none,
229
- 1, 37, :_reduce_none,
230
- 1, 37, :_reduce_16,
231
- 1, 52, :_reduce_none,
232
- 1, 52, :_reduce_none,
233
- 8, 38, :_reduce_19,
234
- 0, 53, :_reduce_20,
235
- 1, 53, :_reduce_21,
236
- 1, 53, :_reduce_none,
237
- 3, 55, :_reduce_23,
238
- 5, 55, :_reduce_24,
239
- 8, 39, :_reduce_25,
240
- 1, 57, :_reduce_26,
241
- 3, 57, :_reduce_27,
242
- 1, 58, :_reduce_none,
243
- 1, 58, :_reduce_none,
244
- 8, 40, :_reduce_30,
245
- 4, 40, :_reduce_31,
246
- 5, 40, :_reduce_32,
247
- 6, 40, :_reduce_33,
248
- 8, 41, :_reduce_34,
249
- 4, 41, :_reduce_35,
250
- 5, 41, :_reduce_36,
251
- 6, 41, :_reduce_37,
252
- 1, 59, :_reduce_38,
253
- 3, 59, :_reduce_39,
254
- 3, 60, :_reduce_40,
255
- 8, 42, :_reduce_41,
256
- 4, 42, :_reduce_42,
257
- 4, 42, :_reduce_43,
258
- 5, 42, :_reduce_44,
259
- 0, 61, :_reduce_45,
260
- 1, 61, :_reduce_none,
261
- 1, 43, :_reduce_47,
262
- 1, 44, :_reduce_48,
221
+ 1, 39, :_reduce_none,
222
+ 1, 39, :_reduce_none,
223
+ 1, 39, :_reduce_none,
224
+ 1, 39, :_reduce_none,
225
+ 1, 39, :_reduce_none,
226
+ 1, 39, :_reduce_none,
227
+ 1, 39, :_reduce_none,
228
+ 1, 39, :_reduce_none,
229
+ 1, 39, :_reduce_none,
230
+ 1, 39, :_reduce_none,
231
+ 1, 39, :_reduce_none,
232
+ 1, 39, :_reduce_none,
233
+ 1, 39, :_reduce_none,
234
+ 1, 39, :_reduce_none,
235
+ 1, 39, :_reduce_none,
236
+ 1, 39, :_reduce_none,
237
+ 1, 39, :_reduce_none,
238
+ 1, 39, :_reduce_18,
239
+ 1, 56, :_reduce_none,
240
+ 1, 56, :_reduce_none,
241
+ 8, 40, :_reduce_21,
242
+ 0, 57, :_reduce_22,
243
+ 1, 57, :_reduce_23,
244
+ 1, 57, :_reduce_none,
245
+ 3, 59, :_reduce_25,
246
+ 5, 59, :_reduce_26,
247
+ 8, 41, :_reduce_27,
248
+ 1, 61, :_reduce_28,
249
+ 3, 61, :_reduce_29,
250
+ 1, 62, :_reduce_none,
251
+ 1, 62, :_reduce_none,
252
+ 8, 42, :_reduce_32,
253
+ 4, 42, :_reduce_33,
254
+ 5, 42, :_reduce_34,
255
+ 6, 42, :_reduce_35,
256
+ 8, 43, :_reduce_36,
257
+ 4, 43, :_reduce_37,
258
+ 5, 43, :_reduce_38,
259
+ 6, 43, :_reduce_39,
260
+ 1, 63, :_reduce_40,
261
+ 3, 63, :_reduce_41,
262
+ 3, 64, :_reduce_42,
263
+ 8, 44, :_reduce_43,
264
+ 4, 44, :_reduce_44,
265
+ 4, 44, :_reduce_45,
266
+ 5, 44, :_reduce_46,
267
+ 0, 65, :_reduce_47,
268
+ 1, 65, :_reduce_none,
263
269
  1, 45, :_reduce_49,
264
- 1, 44, :_reduce_50,
265
- 3, 47, :_reduce_51,
270
+ 1, 46, :_reduce_50,
271
+ 1, 47, :_reduce_51,
266
272
  1, 46, :_reduce_52,
267
- 3, 48, :_reduce_53,
268
- 2, 49, :_reduce_54,
269
- 2, 49, :_reduce_55,
270
- 2, 50, :_reduce_56,
273
+ 3, 49, :_reduce_53,
274
+ 1, 48, :_reduce_54,
275
+ 3, 50, :_reduce_55,
276
+ 2, 51, :_reduce_56,
271
277
  2, 51, :_reduce_57,
272
- 2, 51, :_reduce_58,
273
- 1, 54, :_reduce_59,
274
- 3, 54, :_reduce_60,
275
- 1, 56, :_reduce_61,
276
- 3, 56, :_reduce_62 ]
278
+ 2, 52, :_reduce_58,
279
+ 2, 53, :_reduce_59,
280
+ 2, 53, :_reduce_60,
281
+ 1, 54, :_reduce_61,
282
+ 1, 55, :_reduce_62,
283
+ 1, 58, :_reduce_63,
284
+ 3, 58, :_reduce_64,
285
+ 1, 60, :_reduce_65,
286
+ 3, 60, :_reduce_66 ]
277
287
 
278
- racc_reduce_n = 63
288
+ racc_reduce_n = 67
279
289
 
280
- racc_shift_n = 109
290
+ racc_shift_n = 113
281
291
 
282
292
  racc_token_table = {
283
293
  false => 0,
@@ -315,9 +325,11 @@ racc_token_table = {
315
325
  :REGIONS => 32,
316
326
  :USE => 33,
317
327
  :DESC => 34,
318
- :DESCRIBE => 35 }
328
+ :DESCRIBE => 35,
329
+ :RUBY => 36,
330
+ :EXEC => 37 }
319
331
 
320
- racc_nt_base = 36
332
+ racc_nt_base = 38
321
333
 
322
334
  racc_use_result_var = false
323
335
 
@@ -374,6 +386,8 @@ Racc_token_to_s_table = [
374
386
  "USE",
375
387
  "DESC",
376
388
  "DESCRIBE",
389
+ "RUBY",
390
+ "EXEC",
377
391
  "$start",
378
392
  "stmt",
379
393
  "get_stmt",
@@ -390,6 +404,8 @@ Racc_token_to_s_table = [
390
404
  "show_stmt",
391
405
  "use_stmt",
392
406
  "desc_stmt",
407
+ "ruby_stmt",
408
+ "exec_stmt",
393
409
  "value",
394
410
  "get_output_list",
395
411
  "identifier_list",
@@ -437,56 +453,60 @@ Racc_debug_parser = false
437
453
 
438
454
  # reduce 15 omitted
439
455
 
440
- module_eval(<<'.,.,', 'sdb-parser.y', 20)
441
- def _reduce_16(val, _values)
456
+ # reduce 16 omitted
457
+
458
+ # reduce 17 omitted
459
+
460
+ module_eval(<<'.,.,', 'sdb-parser.y', 22)
461
+ def _reduce_18(val, _values)
442
462
  @stmt_with_expr
443
463
 
444
464
  end
445
465
  .,.,
446
466
 
447
- # reduce 17 omitted
467
+ # reduce 19 omitted
448
468
 
449
- # reduce 18 omitted
469
+ # reduce 20 omitted
450
470
 
451
- module_eval(<<'.,.,', 'sdb-parser.y', 28)
452
- def _reduce_19(val, _values)
471
+ module_eval(<<'.,.,', 'sdb-parser.y', 30)
472
+ def _reduce_21(val, _values)
453
473
  struct(:GET, :domain => val[3], :item_name => val[7], :attr_names => val[1])
454
474
 
455
475
  end
456
476
  .,.,
457
477
 
458
- module_eval(<<'.,.,', 'sdb-parser.y', 33)
459
- def _reduce_20(val, _values)
478
+ module_eval(<<'.,.,', 'sdb-parser.y', 35)
479
+ def _reduce_22(val, _values)
460
480
  []
461
481
 
462
482
  end
463
483
  .,.,
464
484
 
465
- module_eval(<<'.,.,', 'sdb-parser.y', 37)
466
- def _reduce_21(val, _values)
485
+ module_eval(<<'.,.,', 'sdb-parser.y', 39)
486
+ def _reduce_23(val, _values)
467
487
  []
468
488
 
469
489
  end
470
490
  .,.,
471
491
 
472
- # reduce 22 omitted
492
+ # reduce 24 omitted
473
493
 
474
- module_eval(<<'.,.,', 'sdb-parser.y', 43)
475
- def _reduce_23(val, _values)
494
+ module_eval(<<'.,.,', 'sdb-parser.y', 45)
495
+ def _reduce_25(val, _values)
476
496
  [val[1]]
477
497
 
478
498
  end
479
499
  .,.,
480
500
 
481
- module_eval(<<'.,.,', 'sdb-parser.y', 47)
482
- def _reduce_24(val, _values)
501
+ module_eval(<<'.,.,', 'sdb-parser.y', 49)
502
+ def _reduce_26(val, _values)
483
503
  val[0] + [val[3]]
484
504
 
485
505
  end
486
506
  .,.,
487
507
 
488
- module_eval(<<'.,.,', 'sdb-parser.y', 52)
489
- def _reduce_25(val, _values)
508
+ module_eval(<<'.,.,', 'sdb-parser.y', 54)
509
+ def _reduce_27(val, _values)
490
510
  items = val[7].map do |vals|
491
511
  unless val[4].length == vals.length
492
512
  raise Racc::ParseError, 'The number of an attribute and values differs'
@@ -511,26 +531,26 @@ module_eval(<<'.,.,', 'sdb-parser.y', 52)
511
531
  end
512
532
  .,.,
513
533
 
514
- module_eval(<<'.,.,', 'sdb-parser.y', 76)
515
- def _reduce_26(val, _values)
534
+ module_eval(<<'.,.,', 'sdb-parser.y', 78)
535
+ def _reduce_28(val, _values)
516
536
  [val[0]]
517
537
 
518
538
  end
519
539
  .,.,
520
540
 
521
- module_eval(<<'.,.,', 'sdb-parser.y', 80)
522
- def _reduce_27(val, _values)
541
+ module_eval(<<'.,.,', 'sdb-parser.y', 82)
542
+ def _reduce_29(val, _values)
523
543
  val[0] + [val[2]]
524
544
 
525
545
  end
526
546
  .,.,
527
547
 
528
- # reduce 28 omitted
548
+ # reduce 30 omitted
529
549
 
530
- # reduce 29 omitted
550
+ # reduce 31 omitted
531
551
 
532
- module_eval(<<'.,.,', 'sdb-parser.y', 88)
533
- def _reduce_30(val, _values)
552
+ module_eval(<<'.,.,', 'sdb-parser.y', 90)
553
+ def _reduce_32(val, _values)
534
554
  attrs = {}
535
555
  val[3].each {|k, v| attrs[k] = v }
536
556
  struct(:UPDATE, :domain => val[1], :items => [[val[7], attrs]])
@@ -538,8 +558,8 @@ module_eval(<<'.,.,', 'sdb-parser.y', 88)
538
558
  end
539
559
  .,.,
540
560
 
541
- module_eval(<<'.,.,', 'sdb-parser.y', 94)
542
- def _reduce_31(val, _values)
561
+ module_eval(<<'.,.,', 'sdb-parser.y', 96)
562
+ def _reduce_33(val, _values)
543
563
  attrs = {}
544
564
  val[3].each {|k, v| attrs[k] = v }
545
565
  @stmt_with_expr = struct(:UPDATE_WITH_EXPR, :domain => val[1], :attrs => attrs, :expr => '')
@@ -547,8 +567,8 @@ module_eval(<<'.,.,', 'sdb-parser.y', 94)
547
567
  end
548
568
  .,.,
549
569
 
550
- module_eval(<<'.,.,', 'sdb-parser.y', 100)
551
- def _reduce_32(val, _values)
570
+ module_eval(<<'.,.,', 'sdb-parser.y', 102)
571
+ def _reduce_34(val, _values)
552
572
  attrs = {}
553
573
  val[3].each {|k, v| attrs[k] = v }
554
574
  @stmt_with_expr = struct(:UPDATE_WITH_EXPR, :domain => val[1], :attrs => attrs, :expr => 'WHERE ')
@@ -556,8 +576,8 @@ module_eval(<<'.,.,', 'sdb-parser.y', 100)
556
576
  end
557
577
  .,.,
558
578
 
559
- module_eval(<<'.,.,', 'sdb-parser.y', 106)
560
- def _reduce_33(val, _values)
579
+ module_eval(<<'.,.,', 'sdb-parser.y', 108)
580
+ def _reduce_35(val, _values)
561
581
  attrs = {}
562
582
  val[3].each {|k, v| attrs[k] = v }
563
583
  @stmt_with_expr = struct(:UPDATE_WITH_EXPR, :domain => val[1], :attrs => attrs, :expr => 'WHERE itemName')
@@ -565,8 +585,8 @@ module_eval(<<'.,.,', 'sdb-parser.y', 106)
565
585
  end
566
586
  .,.,
567
587
 
568
- module_eval(<<'.,.,', 'sdb-parser.y', 113)
569
- def _reduce_34(val, _values)
588
+ module_eval(<<'.,.,', 'sdb-parser.y', 115)
589
+ def _reduce_36(val, _values)
570
590
  attrs = {}
571
591
  val[3].each {|k, v| attrs[k] = v }
572
592
  struct(:MERGE, :domain => val[1], :items => [[val[7], attrs]])
@@ -574,8 +594,8 @@ module_eval(<<'.,.,', 'sdb-parser.y', 113)
574
594
  end
575
595
  .,.,
576
596
 
577
- module_eval(<<'.,.,', 'sdb-parser.y', 119)
578
- def _reduce_35(val, _values)
597
+ module_eval(<<'.,.,', 'sdb-parser.y', 121)
598
+ def _reduce_37(val, _values)
579
599
  attrs = {}
580
600
  val[3].each {|k, v| attrs[k] = v }
581
601
  @stmt_with_expr = struct(:MERGE_WITH_EXPR, :domain => val[1], :attrs => attrs, :expr => '')
@@ -583,8 +603,8 @@ module_eval(<<'.,.,', 'sdb-parser.y', 119)
583
603
  end
584
604
  .,.,
585
605
 
586
- module_eval(<<'.,.,', 'sdb-parser.y', 125)
587
- def _reduce_36(val, _values)
606
+ module_eval(<<'.,.,', 'sdb-parser.y', 127)
607
+ def _reduce_38(val, _values)
588
608
  attrs = {}
589
609
  val[3].each {|k, v| attrs[k] = v }
590
610
  @stmt_with_expr = struct(:MERGE_WITH_EXPR, :domain => val[1], :attrs => attrs, :expr => 'WHERE ')
@@ -592,8 +612,8 @@ module_eval(<<'.,.,', 'sdb-parser.y', 125)
592
612
  end
593
613
  .,.,
594
614
 
595
- module_eval(<<'.,.,', 'sdb-parser.y', 131)
596
- def _reduce_37(val, _values)
615
+ module_eval(<<'.,.,', 'sdb-parser.y', 133)
616
+ def _reduce_39(val, _values)
597
617
  attrs = {}
598
618
  val[3].each {|k, v| attrs[k] = v }
599
619
  @stmt_with_expr = struct(:MERGE_WITH_EXPR, :domain => val[1], :attrs => attrs, :expr => 'WHERE itemName')
@@ -601,66 +621,66 @@ module_eval(<<'.,.,', 'sdb-parser.y', 131)
601
621
  end
602
622
  .,.,
603
623
 
604
- module_eval(<<'.,.,', 'sdb-parser.y', 138)
605
- def _reduce_38(val, _values)
624
+ module_eval(<<'.,.,', 'sdb-parser.y', 140)
625
+ def _reduce_40(val, _values)
606
626
  [val[0]]
607
627
 
608
628
  end
609
629
  .,.,
610
630
 
611
- module_eval(<<'.,.,', 'sdb-parser.y', 142)
612
- def _reduce_39(val, _values)
631
+ module_eval(<<'.,.,', 'sdb-parser.y', 144)
632
+ def _reduce_41(val, _values)
613
633
  val[0] + [val[2]]
614
634
 
615
635
  end
616
636
  .,.,
617
637
 
618
- module_eval(<<'.,.,', 'sdb-parser.y', 147)
619
- def _reduce_40(val, _values)
638
+ module_eval(<<'.,.,', 'sdb-parser.y', 149)
639
+ def _reduce_42(val, _values)
620
640
  [val[0], val[2]]
621
641
 
622
642
  end
623
643
  .,.,
624
644
 
625
- module_eval(<<'.,.,', 'sdb-parser.y', 152)
626
- def _reduce_41(val, _values)
645
+ module_eval(<<'.,.,', 'sdb-parser.y', 154)
646
+ def _reduce_43(val, _values)
627
647
  struct(:DELETE, :domain => val[3], :items => [[val[7], val[1]]])
628
648
 
629
649
  end
630
650
  .,.,
631
651
 
632
- module_eval(<<'.,.,', 'sdb-parser.y', 156)
633
- def _reduce_42(val, _values)
652
+ module_eval(<<'.,.,', 'sdb-parser.y', 158)
653
+ def _reduce_44(val, _values)
634
654
  @stmt_with_expr = struct(:DELETE_WITH_EXPR, :domain => val[3], :attrs => val[1], :expr => '')
635
655
 
636
656
  end
637
657
  .,.,
638
658
 
639
- module_eval(<<'.,.,', 'sdb-parser.y', 160)
640
- def _reduce_43(val, _values)
659
+ module_eval(<<'.,.,', 'sdb-parser.y', 162)
660
+ def _reduce_45(val, _values)
641
661
  @stmt_with_expr = struct(:DELETE_WITH_EXPR, :domain => val[3], :attrs => val[1], :expr => 'WHERE ')
642
662
 
643
663
  end
644
664
  .,.,
645
665
 
646
- module_eval(<<'.,.,', 'sdb-parser.y', 164)
647
- def _reduce_44(val, _values)
666
+ module_eval(<<'.,.,', 'sdb-parser.y', 166)
667
+ def _reduce_46(val, _values)
648
668
  @stmt_with_expr = struct(:DELETE_WITH_EXPR, :domain => val[3], :attrs => val[1], :expr => 'WHERE itemName')
649
669
 
650
670
  end
651
671
  .,.,
652
672
 
653
- module_eval(<<'.,.,', 'sdb-parser.y', 169)
654
- def _reduce_45(val, _values)
673
+ module_eval(<<'.,.,', 'sdb-parser.y', 171)
674
+ def _reduce_47(val, _values)
655
675
  []
656
676
 
657
677
  end
658
678
  .,.,
659
679
 
660
- # reduce 46 omitted
680
+ # reduce 48 omitted
661
681
 
662
- module_eval(<<'.,.,', 'sdb-parser.y', 175)
663
- def _reduce_47(val, _values)
682
+ module_eval(<<'.,.,', 'sdb-parser.y', 177)
683
+ def _reduce_49(val, _values)
664
684
  query = ''
665
685
  ruby = nil
666
686
 
@@ -687,39 +707,39 @@ module_eval(<<'.,.,', 'sdb-parser.y', 175)
687
707
  end
688
708
  .,.,
689
709
 
690
- module_eval(<<'.,.,', 'sdb-parser.y', 201)
691
- def _reduce_48(val, _values)
710
+ module_eval(<<'.,.,', 'sdb-parser.y', 203)
711
+ def _reduce_50(val, _values)
692
712
  ruby = val[0].sub(/\A\s*\|\s*/, '') if val[0]
693
713
  struct(:NEXT, :ruby => ruby)
694
714
 
695
715
  end
696
716
  .,.,
697
717
 
698
- module_eval(<<'.,.,', 'sdb-parser.y', 207)
699
- def _reduce_49(val, _values)
718
+ module_eval(<<'.,.,', 'sdb-parser.y', 209)
719
+ def _reduce_51(val, _values)
700
720
  ruby = val[0].sub(/\A\s*\|\s*/, '') if val[0]
701
721
  struct(:CURRENT, :ruby => ruby)
702
722
 
703
723
  end
704
724
  .,.,
705
725
 
706
- module_eval(<<'.,.,', 'sdb-parser.y', 213)
707
- def _reduce_50(val, _values)
726
+ module_eval(<<'.,.,', 'sdb-parser.y', 215)
727
+ def _reduce_52(val, _values)
708
728
  ruby = val[0].sub(/\A\s*\|\s*/, '') if val[0]
709
729
  struct(:PREV, :ruby => ruby)
710
730
 
711
731
  end
712
732
  .,.,
713
733
 
714
- module_eval(<<'.,.,', 'sdb-parser.y', 219)
715
- def _reduce_51(val, _values)
734
+ module_eval(<<'.,.,', 'sdb-parser.y', 221)
735
+ def _reduce_53(val, _values)
716
736
  struct(:CREATE, :domain => val[2])
717
737
 
718
738
  end
719
739
  .,.,
720
740
 
721
- module_eval(<<'.,.,', 'sdb-parser.y', 224)
722
- def _reduce_52(val, _values)
741
+ module_eval(<<'.,.,', 'sdb-parser.y', 226)
742
+ def _reduce_54(val, _values)
723
743
  page, ruby = val[0].split(/\s*\|\s*/, 2)
724
744
  page = page.split(/\s+/, 2)[1]
725
745
  page = page.strip.to_i if page
@@ -728,71 +748,87 @@ module_eval(<<'.,.,', 'sdb-parser.y', 224)
728
748
  end
729
749
  .,.,
730
750
 
731
- module_eval(<<'.,.,', 'sdb-parser.y', 232)
732
- def _reduce_53(val, _values)
751
+ module_eval(<<'.,.,', 'sdb-parser.y', 234)
752
+ def _reduce_55(val, _values)
733
753
  struct(:DROP, :domain => val[2])
734
754
 
735
755
  end
736
756
  .,.,
737
757
 
738
- module_eval(<<'.,.,', 'sdb-parser.y', 237)
739
- def _reduce_54(val, _values)
758
+ module_eval(<<'.,.,', 'sdb-parser.y', 239)
759
+ def _reduce_56(val, _values)
740
760
  struct(:SHOW, :operand => :domains)
741
761
 
742
762
  end
743
763
  .,.,
744
764
 
745
- module_eval(<<'.,.,', 'sdb-parser.y', 241)
746
- def _reduce_55(val, _values)
765
+ module_eval(<<'.,.,', 'sdb-parser.y', 243)
766
+ def _reduce_57(val, _values)
747
767
  struct(:SHOW, :operand => :regions)
748
768
 
749
769
  end
750
770
  .,.,
751
771
 
752
- module_eval(<<'.,.,', 'sdb-parser.y', 245)
753
- def _reduce_56(val, _values)
772
+ module_eval(<<'.,.,', 'sdb-parser.y', 247)
773
+ def _reduce_58(val, _values)
754
774
  struct(:USE, :endpoint => val[1])
755
775
 
756
776
  end
757
777
  .,.,
758
778
 
759
- module_eval(<<'.,.,', 'sdb-parser.y', 249)
760
- def _reduce_57(val, _values)
779
+ module_eval(<<'.,.,', 'sdb-parser.y', 251)
780
+ def _reduce_59(val, _values)
761
781
  struct(:DESCRIBE, :domain => val[1])
762
782
 
763
783
  end
764
784
  .,.,
765
785
 
766
- module_eval(<<'.,.,', 'sdb-parser.y', 253)
767
- def _reduce_58(val, _values)
786
+ module_eval(<<'.,.,', 'sdb-parser.y', 255)
787
+ def _reduce_60(val, _values)
768
788
  struct(:DESCRIBE, :domain => val[1])
769
789
 
770
790
  end
771
791
  .,.,
772
792
 
773
- module_eval(<<'.,.,', 'sdb-parser.y', 258)
774
- def _reduce_59(val, _values)
793
+ module_eval(<<'.,.,', 'sdb-parser.y', 259)
794
+ def _reduce_61(val, _values)
795
+ script = val[0].sub(/\A\s*\|\s*/, '')
796
+ struct(:RUBY, :script => script)
797
+
798
+ end
799
+ .,.,
800
+
801
+ module_eval(<<'.,.,', 'sdb-parser.y', 264)
802
+ def _reduce_62(val, _values)
803
+ script = val[0].sub(/\A\s*!\s*/, '')
804
+ struct(:EXEC, :script => script)
805
+
806
+ end
807
+ .,.,
808
+
809
+ module_eval(<<'.,.,', 'sdb-parser.y', 270)
810
+ def _reduce_63(val, _values)
775
811
  [val[0]]
776
812
 
777
813
  end
778
814
  .,.,
779
815
 
780
- module_eval(<<'.,.,', 'sdb-parser.y', 262)
781
- def _reduce_60(val, _values)
816
+ module_eval(<<'.,.,', 'sdb-parser.y', 274)
817
+ def _reduce_64(val, _values)
782
818
  val[0] + [val[2]]
783
819
 
784
820
  end
785
821
  .,.,
786
822
 
787
- module_eval(<<'.,.,', 'sdb-parser.y', 267)
788
- def _reduce_61(val, _values)
823
+ module_eval(<<'.,.,', 'sdb-parser.y', 279)
824
+ def _reduce_65(val, _values)
789
825
  [val[0]]
790
826
 
791
827
  end
792
828
  .,.,
793
829
 
794
- module_eval(<<'.,.,', 'sdb-parser.y', 271)
795
- def _reduce_62(val, _values)
830
+ module_eval(<<'.,.,', 'sdb-parser.y', 283)
831
+ def _reduce_66(val, _values)
796
832
  [val[0], val[2]].flatten
797
833
 
798
834
  end
@@ -16,6 +16,8 @@ rule
16
16
  | show_stmt
17
17
  | use_stmt
18
18
  | desc_stmt
19
+ | ruby_stmt
20
+ | exec_stmt
19
21
  | error
20
22
  {
21
23
  @stmt_with_expr
@@ -253,6 +255,16 @@ rule
253
255
  {
254
256
  struct(:DESCRIBE, :domain => val[1])
255
257
  }
258
+ ruby_stmt : RUBY
259
+ {
260
+ script = val[0].sub(/\A\s*\|\s*/, '')
261
+ struct(:RUBY, :script => script)
262
+ }
263
+ exec_stmt : EXEC
264
+ {
265
+ script = val[0].sub(/\A\s*!\s*/, '')
266
+ struct(:EXEC, :script => script)
267
+ }
256
268
 
257
269
  identifier_list: IDENTIFIER
258
270
  {
@@ -375,6 +387,10 @@ def scan
375
387
  yield [tok, tok]
376
388
  elsif (tok = @ss.scan /[a-z_$][-0-9a-z_$.]*\b/i)
377
389
  yield [:IDENTIFIER, tok]
390
+ elsif (tok = @ss.scan /\|/i)
391
+ yield [:RUBY, @ss.scan(/.*/)]
392
+ elsif (tok = @ss.scan /!/i)
393
+ yield [:EXEC, @ss.scan(/.*/)]
378
394
  else
379
395
  raise Racc::ParseError, ('parse error on value "%s"' % @ss.rest.inspect)
380
396
  end
@@ -168,6 +168,48 @@ module SimpleDB
168
168
  end
169
169
  end
170
170
  end
171
+
172
+ def items.group_by(name, &block)
173
+ item_h = {}
174
+
175
+ self.each do |item|
176
+ key = item[1][name.to_s]
177
+
178
+ unless item_h[key]
179
+ item_list = []
180
+
181
+ def item_list.method_missing(method_name)
182
+ case method_name.to_s
183
+ when /itemName/i
184
+ self.map {|i| i[0] }
185
+ else
186
+ self.map {|i| i[1][method_name.to_s] }
187
+ end
188
+ end
189
+
190
+ item_h[key] = item_list
191
+ end
192
+
193
+ item_h[key] << item
194
+ end
195
+
196
+ if block
197
+ old_item_h = item_h
198
+ item_h = {}
199
+
200
+ old_item_h.each do |key, item_list|
201
+ if block.arity == 2
202
+ new_item_list = block.call(item_list, key)
203
+ else
204
+ new_item_list = block.call(item_list)
205
+ end
206
+
207
+ item_h[key] = new_item_list
208
+ end
209
+ end
210
+
211
+ item_h
212
+ end
171
213
  end
172
214
 
173
215
  if parsed.ruby
@@ -207,6 +249,10 @@ module SimpleDB
207
249
  nil
208
250
  when :DESCRIBE
209
251
  @driver.describe(parsed.domain)
252
+ when :RUBY
253
+ eval(parsed.script.strip)
254
+ when :EXEC
255
+ `#{parsed.script.strip}`
210
256
  else
211
257
  raise 'must not happen'
212
258
  end
metadata CHANGED
@@ -1,55 +1,59 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: sdbcli
3
- version: !ruby/object:Gem::Version
4
- version: 1.4.2
3
+ version: !ruby/object:Gem::Version
4
+ hash: 1
5
5
  prerelease:
6
+ segments:
7
+ - 1
8
+ - 4
9
+ - 3
10
+ version: 1.4.3
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - winebarrel
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2013-02-04 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2013-02-05 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: nokogiri
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
22
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: json
32
- requirement: !ruby/object:Gem::Requirement
23
+ requirement: &id001 !ruby/object:Gem::Requirement
33
24
  none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
38
32
  type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: json
39
36
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
37
+ requirement: &id002 !ruby/object:Gem::Requirement
41
38
  none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ type: :runtime
47
+ version_requirements: *id002
46
48
  description:
47
49
  email: sgwr_dts@yahoo.co.jp
48
- executables:
50
+ executables:
49
51
  - sdbcli
50
52
  extensions: []
53
+
51
54
  extra_rdoc_files: []
52
- files:
55
+
56
+ files:
53
57
  - README
54
58
  - bin/sdbcli
55
59
  - lib/sdbcli/sdb-client.rb
@@ -61,26 +65,36 @@ files:
61
65
  - lib/sdbcli.rb
62
66
  homepage: https://bitbucket.org/winebarrel/sdbcli
63
67
  licenses: []
68
+
64
69
  post_install_message:
65
70
  rdoc_options: []
66
- require_paths:
71
+
72
+ require_paths:
67
73
  - lib
68
- required_ruby_version: !ruby/object:Gem::Requirement
74
+ required_ruby_version: !ruby/object:Gem::Requirement
69
75
  none: false
70
- requirements:
71
- - - ! '>='
72
- - !ruby/object:Gem::Version
73
- version: '0'
74
- required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ hash: 3
80
+ segments:
81
+ - 0
82
+ version: "0"
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
84
  none: false
76
- requirements:
77
- - - ! '>='
78
- - !ruby/object:Gem::Version
79
- version: '0'
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
91
+ version: "0"
80
92
  requirements: []
93
+
81
94
  rubyforge_project:
82
- rubygems_version: 1.8.23
95
+ rubygems_version: 1.8.24
83
96
  signing_key:
84
97
  specification_version: 3
85
98
  summary: sdbcli is an interactive command-line client of Amazon SimpleDB.
86
99
  test_files: []
100
+