ddbcli 0.3.8 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -82,6 +82,11 @@ rule
82
82
  struct(:USE, :endpoint_or_region => val[1])
83
83
  }
84
84
 
85
+ | USE STRING
86
+ {
87
+ struct(:USE, :endpoint_or_region => val[1])
88
+ }
89
+
85
90
  create_stmt : CREATE TABLE IDENTIFIER '(' create_definition ')' capacity_clause
86
91
  {
87
92
  struct(:CREATE, val[4].merge(:table => val[2], :capacity => val[6]))
@@ -395,6 +400,18 @@ rule
395
400
  {
396
401
  struct(:UPDATE_ALL, :table => val[2], :action => val[3], :attrs => val[4], :conds => val[5], :limit => val[6])
397
402
  }
403
+ | UPDATE IDENTIFIER delete_or_del identifier_list update_where_clause
404
+ {
405
+ attrs = {}
406
+ val[3].each {|i| attrs[i] = true }
407
+ struct(:UPDATE, :table => val[1], :action => val[2], :attrs => attrs, :conds => val[4])
408
+ }
409
+ | UPDATE ALL IDENTIFIER delete_or_del identifier_list scan_where_clause limit_clause
410
+ {
411
+ attrs = {}
412
+ val[4].each {|i| attrs[i] = true }
413
+ struct(:UPDATE_ALL, :table => val[2], :action => val[3], :attrs => attrs, :conds => val[5], :limit => val[6])
414
+ }
398
415
 
399
416
  set_or_add : SET
400
417
  {
@@ -405,6 +422,15 @@ rule
405
422
  :ADD
406
423
  }
407
424
 
425
+ delete_or_del : DELETE
426
+ {
427
+ :DELETE
428
+ }
429
+ | DEL
430
+ {
431
+ :DELETE
432
+ }
433
+
408
434
  attr_to_update_list : attr_to_update
409
435
  {
410
436
  [val[0]]
@@ -414,7 +440,7 @@ rule
414
440
  val[0] + [val[2]]
415
441
  }
416
442
 
417
- attr_to_update : IDENTIFIER EQ value_or_null
443
+ attr_to_update : IDENTIFIER EQ value
418
444
  {
419
445
  [val[0], val[2]]
420
446
  }
@@ -485,10 +511,51 @@ rule
485
511
  struct(:NEXT)
486
512
  }
487
513
 
488
- value_or_null : value | NULL
489
-
490
514
  value : single_value
491
515
  | value_list
516
+ | list
517
+ | map
518
+ | BOOL
519
+ | NULL
520
+
521
+ list : '[' ']'
522
+ | '[' list_items ']'
523
+ {
524
+ val[1]
525
+ }
526
+
527
+ list_items : value
528
+ {
529
+ [val[0]]
530
+ }
531
+ | list_items ',' value
532
+ {
533
+ val[0] + [val[2]]
534
+ }
535
+
536
+ map : '{' '}'
537
+ {
538
+ {}
539
+ }
540
+ | '{' map_items '}'
541
+ {
542
+ val[1]
543
+ }
544
+
545
+ map_items : map_item
546
+ | map_items ',' map_item
547
+ {
548
+ val[0].merge(val[2])
549
+ }
550
+
551
+ map_item : IDENTIFIER ':' value
552
+ {
553
+ {val[0] => val[2]}
554
+ }
555
+ | STRING ':' value
556
+ {
557
+ {val[0] => val[2]}
558
+ }
492
559
 
493
560
  single_value : NUMBER_VALUE
494
561
  | STRING_VALUE
@@ -509,29 +576,29 @@ rule
509
576
 
510
577
  number_list : NUMBER_VALUE
511
578
  {
512
- [val[0]]
579
+ Set[val[0]]
513
580
  }
514
581
  | number_list ',' NUMBER_VALUE
515
582
  {
516
- val[0] + [val[2]]
583
+ val[0] + Set[val[2]]
517
584
  }
518
585
 
519
586
  string_list : STRING_VALUE
520
587
  {
521
- [val[0]]
588
+ Set[val[0]]
522
589
  }
523
590
  | string_list ',' STRING_VALUE
524
591
  {
525
- val[0] + [val[2]]
592
+ val[0] + Set[val[2]]
526
593
  }
527
594
 
528
595
  binary_list : BINARY_VALUE
529
596
  {
530
- [val[0]]
597
+ Set[val[0]]
531
598
  }
532
599
  | binary_list ',' BINARY_VALUE
533
600
  {
534
- val[0] + [val[2]]
601
+ val[0] + Set[val[2]]
535
602
  }
536
603
 
537
604
  identifier_list : IDENTIFIER
@@ -547,6 +614,7 @@ rule
547
614
 
548
615
  require 'strscan'
549
616
  require 'ddbcli/ddb-binary'
617
+ require 'set'
550
618
 
551
619
  module DynamoDB
552
620
 
@@ -566,6 +634,7 @@ KEYWORDS = %w(
566
634
  CONTAINS
567
635
  COUNT
568
636
  DELETE
637
+ DEL
569
638
  DESCRIBE
570
639
  DESC
571
640
  DROP
@@ -668,14 +737,20 @@ def scan
668
737
  yield [:STRING_VALUE, tok.slice(1...-1).gsub(/""/, '"')]
669
738
  elsif (tok = @ss.scan /\d+(?:\.\d+)?/)
670
739
  yield [:NUMBER_VALUE, (tok =~ /\./ ? tok.to_f : tok.to_i)]
671
- elsif (tok = @ss.scan /[,\(\)\*\/]/)
740
+ elsif (tok = @ss.scan /[,\(\)\*\/\[\]\{\}:]/)
672
741
  yield [tok, tok]
673
742
  elsif (tok = @ss.scan /\|(?:.*)/)
674
743
  yield [:RUBY_SCRIPT, tok.slice(1..-1)]
744
+ elsif (tok = @ss.scan /\|(?:.*)/)
745
+ yield [:RUBY_SCRIPT, tok.slice(1..-1)]
675
746
  elsif (tok = @ss.scan /\!(?:.*)/)
676
747
  yield [:SHELL_SCRIPT, tok.slice(1..-1)]
677
- elsif (tok = @ss.scan %r|[-.0-9a-z_:/]*|i)
678
- yield [:IDENTIFIER, tok]
748
+ elsif (tok = @ss.scan %r|[-.0-9a-z_]*|i)
749
+ if ['true', 'false'].include?(tok)
750
+ yield [:BOOL, 'true' == tok]
751
+ else
752
+ yield [:IDENTIFIER, tok]
753
+ end
679
754
  else
680
755
  raise_error(tok, @prev_tokens, @ss)
681
756
  end
@@ -1,5 +1,5 @@
1
1
  module DynamoDB
2
- VERSION = "0.3.8"
2
+ VERSION = "0.4.0"
3
3
  end
4
4
 
5
5
  Version = DynamoDB::VERSION
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddbcli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-18 00:00:00.000000000 Z
11
+ date: 2014-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -81,6 +81,7 @@ files:
81
81
  - Rakefile
82
82
  - bin/ddbcli
83
83
  - ddbcli.gemspec
84
+ - etc/ddbcli-demo.gif
84
85
  - etc/pack_to_one_script.rb
85
86
  - lib/ddbcli.rb
86
87
  - lib/ddbcli/cli/evaluate.rb
@@ -103,7 +104,7 @@ files:
103
104
  - spec/select_spec.rb
104
105
  - spec/spec_helper.rb
105
106
  - spec/update_spec.rb
106
- homepage: https://bitbucket.org/winebarrel/ddbcli
107
+ homepage: https://github.com/winebarrel/ddbcli
107
108
  licenses:
108
109
  - MIT
109
110
  metadata: {}
@@ -123,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
124
  version: '0'
124
125
  requirements: []
125
126
  rubyforge_project:
126
- rubygems_version: 2.0.14
127
+ rubygems_version: 2.4.1
127
128
  signing_key:
128
129
  specification_version: 4
129
130
  summary: ddbcli is an interactive command-line client of Amazon DynamoDB.