awful 0.0.121 → 0.0.122
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/awful/dynamodb.rb +23 -0
- data/lib/awful/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb0baf3ba2651e052ce2259d7495a43c3391575c
|
4
|
+
data.tar.gz: dcfa81feb089d645cf4a1cf5b8a0121062505d3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c7b2aa817311f522ee58fe346ead64a76cdcf712f00d50f165057986b536ff63731a12916aca8c4c105c296d249db1d7382fa8a20b9fd2e7d7d27349e97274a
|
7
|
+
data.tar.gz: 8dda804f8cd2168e84221f6b1ad30b01efb65da85751d1d8ff152b1fe4ac0229d059b5840f27b23e07510807b86db5ae4e2f92972572ac8ac642c4c97d864b8b
|
data/lib/awful/dynamodb.rb
CHANGED
@@ -237,6 +237,29 @@ module Awful
|
|
237
237
|
fd.close
|
238
238
|
end
|
239
239
|
|
240
|
+
desc 'query NAME', 'query table with NAME'
|
241
|
+
method_option :hash_key, aliases: '-k', type: :string, default: nil, desc: 'Hash key'
|
242
|
+
method_option :hash_key_value, aliases: '-v', type: :string, default: nil, desc: 'Hash key value'
|
243
|
+
method_option :output, aliases: '-o', type: :string, default: nil, desc: 'Output filename (default: stdout)'
|
244
|
+
def query(name, exclusive_start_key = nil)
|
245
|
+
fd = options[:output] ? File.open(options[:output], 'w') : $stdout.dup # open output file or stdout
|
246
|
+
exclusive_start_key = nil
|
247
|
+
loop do
|
248
|
+
r = dynamodb_simple.query(
|
249
|
+
'TableName' => name,
|
250
|
+
'ExclusiveStartKey' => exclusive_start_key,
|
251
|
+
'KeyConditionExpression' => "#{options[:hash_key]} = :hash_key_value",
|
252
|
+
'ExpressionAttributeValues' => { ":hash_key_value" => { S: options[:hash_key_value] } }
|
253
|
+
)
|
254
|
+
r['Items'].each do |item|
|
255
|
+
fd.puts JSON.generate(item)
|
256
|
+
end
|
257
|
+
exclusive_start_key = r['LastEvaluatedKey']
|
258
|
+
break unless exclusive_start_key
|
259
|
+
end
|
260
|
+
fd.close
|
261
|
+
end
|
262
|
+
|
240
263
|
desc 'put_items NAME', 'puts json items into the table with NAME'
|
241
264
|
method_option :no_clobber, aliases: '-n', type: :boolean, default: false, desc: 'Do not overwrite existing items'
|
242
265
|
def put_items(name, file = nil)
|
data/lib/awful/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.122
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ric Lister
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|