sdbcli 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README +10 -1
- data/bin/sdbcli +10 -2
- data/lib/sdbcli/sdb-runner.rb +10 -4
- metadata +4 -4
data/README
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
== Description
|
4
4
|
|
5
|
-
sdbcli is interactive command-line client of Amazon SimpleDB.
|
5
|
+
sdbcli is an interactive command-line client of Amazon SimpleDB.
|
6
6
|
|
7
7
|
== Source Code
|
8
8
|
|
@@ -47,6 +47,15 @@ https://bitbucket.org/winebarrel/sdbcli
|
|
47
47
|
---
|
48
48
|
- [itemname1, {attr1: val1, attr2: val2}]
|
49
49
|
- [itemname2, {attr1: val1, attr2: val2}]
|
50
|
+
ap-northeast-1> select * from test \G
|
51
|
+
---
|
52
|
+
- - itemname1
|
53
|
+
- attr1: val1
|
54
|
+
attr2: val2
|
55
|
+
- itemname2
|
56
|
+
- attr1: val1
|
57
|
+
attr2: val2
|
58
|
+
|
50
59
|
|
51
60
|
shell> echo 'select * from test' | sdbcli
|
52
61
|
---
|
data/bin/sdbcli
CHANGED
@@ -27,7 +27,15 @@ end
|
|
27
27
|
$runner = SimpleDB::Runner.new(access_key_id, secret_access_key, sdb_endpoint)
|
28
28
|
|
29
29
|
def execute(query)
|
30
|
-
|
30
|
+
query = query.strip.sub(/\s*;\Z/, '')
|
31
|
+
inline = true
|
32
|
+
|
33
|
+
if query =~ /\s*\\G\Z/i
|
34
|
+
query = query.sub(/\s*\\G\Z/i, '')
|
35
|
+
inline = false
|
36
|
+
end
|
37
|
+
|
38
|
+
out = $runner.execute(query, inline)
|
31
39
|
puts YAML.dump(out) if out
|
32
40
|
end
|
33
41
|
|
@@ -79,7 +87,7 @@ while buf = Readline.readline("#{region}> ", true)
|
|
79
87
|
when 'exit', 'quit'
|
80
88
|
exit
|
81
89
|
else
|
82
|
-
execute(buf
|
90
|
+
execute(buf)
|
83
91
|
end
|
84
92
|
rescue => e
|
85
93
|
puts e.message.strip
|
data/lib/sdbcli/sdb-runner.rb
CHANGED
@@ -17,14 +17,18 @@ module SimpleDB
|
|
17
17
|
@driver.endpoint = v
|
18
18
|
end
|
19
19
|
|
20
|
-
def execute(query)
|
20
|
+
def execute(query, inline = true)
|
21
21
|
parsed = Parser.parse(query)
|
22
22
|
command = parsed.class.name.split('::').last.to_sym
|
23
23
|
|
24
24
|
case command
|
25
25
|
when :GET
|
26
26
|
item = @driver.get(parsed.domain, parsed.item_name, parsed.attr_names)
|
27
|
-
|
27
|
+
|
28
|
+
if inline
|
29
|
+
def item.to_yaml_style; :inline; end
|
30
|
+
end
|
31
|
+
|
28
32
|
item
|
29
33
|
when :INSERT
|
30
34
|
@driver.insert(parsed.domain, parsed.item_name, parsed.attrs)
|
@@ -38,8 +42,10 @@ module SimpleDB
|
|
38
42
|
when :SELECT
|
39
43
|
items = @driver.select(parsed.query)
|
40
44
|
|
41
|
-
|
42
|
-
|
45
|
+
if inline
|
46
|
+
items.each do |item|
|
47
|
+
def item.to_yaml_style; :inline; end
|
48
|
+
end
|
43
49
|
end
|
44
50
|
|
45
51
|
items
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sdbcli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- winebarrel
|
@@ -80,6 +80,6 @@ rubyforge_project:
|
|
80
80
|
rubygems_version: 1.8.11
|
81
81
|
signing_key:
|
82
82
|
specification_version: 3
|
83
|
-
summary: sdbcli is interactive command-line client of Amazon SimpleDB.
|
83
|
+
summary: sdbcli is an interactive command-line client of Amazon SimpleDB.
|
84
84
|
test_files: []
|
85
85
|
|