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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0013087de23aa3029310865e2261704ae16bb20
4
- data.tar.gz: 18001ac5b7e3f83fae97b1c92e576f64d84eb273
3
+ metadata.gz: cb0baf3ba2651e052ce2259d7495a43c3391575c
4
+ data.tar.gz: dcfa81feb089d645cf4a1cf5b8a0121062505d3b
5
5
  SHA512:
6
- metadata.gz: aa50e851e9319d4b46bc793d6a3bdc8109dde45c09f5a1b074d73a646e0bac74c2aba7d340e02e63ca456f8416d35abe02dd95994ad4d22ac1390d7e6a448341
7
- data.tar.gz: 8fc3e2222761bd4f995816377cc915cfc5ec9772bf6ef62b3d05724f1b497592ef97cc95cb98b76f9578914bcaf645eb4d6786ba8b563ba64a3947886c28445c
6
+ metadata.gz: 4c7b2aa817311f522ee58fe346ead64a76cdcf712f00d50f165057986b536ff63731a12916aca8c4c105c296d249db1d7382fa8a20b9fd2e7d7d27349e97274a
7
+ data.tar.gz: 8dda804f8cd2168e84221f6b1ad30b01efb65da85751d1d8ff152b1fe4ac0229d059b5840f27b23e07510807b86db5ae4e2f92972572ac8ac642c4c97d864b8b
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Awful
2
- VERSION = '0.0.121'
2
+ VERSION = '0.0.122'
3
3
  end
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.121
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-07 00:00:00.000000000 Z
11
+ date: 2016-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler