awful 0.0.50 → 0.0.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f12925d0bab66ac09364ba581a5f6ee28c44f913
4
- data.tar.gz: 04f50da9a56ac7720ed49fc2d363646874666425
3
+ metadata.gz: 2888a7ad42f76efc66392da142e9b62773c5c0db
4
+ data.tar.gz: 6eee728975b75a92630a22e6cb782262491272bc
5
5
  SHA512:
6
- metadata.gz: fe326b2911daeb85415e25cb03661a50024b6808b8ee9902afeaff221cede87f59454d08938362985b5465c9c887eee2397d558822ba0132423e96c2df11bb84
7
- data.tar.gz: 1f3ff88f3722080a089046ffda92ef5c7df7f04309947e3532348558cc0fa9ad2ad33dc8ca1c3b7e51aec1997eecda91145679a37160ab218e14f48e98c06fce
6
+ metadata.gz: b75300afbde05e5e03698bf2314f634d0137ad5e7340a15d09e6c29f576e7800ef762a3a3be08fab737981e649585db33f5455468c7ae76a9a62679dfb2a4d85
7
+ data.tar.gz: 309eee4a3dc1dd434c1c582597cacb69e20ea4d007e363b8c070ed04b5dde42639fd88198b0da57ec8c6100be2977a582ef03a28429160ee9dccb99e072b8187
@@ -66,19 +66,30 @@ module Awful
66
66
  end
67
67
  end
68
68
 
69
- ## uses simple_json to get Aws::Plugins::Protocols::JsonRpc output from scan;
70
- ## this also means request params need to be raw strings and not symbols, etc
71
- desc 'scan NAME', 'scan table with NAME'
72
- def scan(name, exclusive_start_key = nil)
73
- r = dynamodb_simple.scan('TableName' => name, 'ExclusiveStartKey' => exclusive_start_key)
74
- puts r['Items'].map { |item| JSON.generate(item) }.join("\n")
69
+ no_commands do
70
+ ## uses simple_json to get Aws::Plugins::Protocols::JsonRpc output from scan;
71
+ ## this also means request params need to be raw strings and not symbols, etc
72
+ def scan_to_file(name, exclusive_start_key, fd)
73
+ r = dynamodb_simple.scan('TableName' => name, 'ExclusiveStartKey' => exclusive_start_key)
74
+ r['Items'].each do |item|
75
+ fd.puts JSON.generate(item)
76
+ end
75
77
 
76
- ## recurse if more data to get
77
- if r.has_key?('LastEvaluatedKey')
78
- scan(name, r['LastEvaluatedKey'])
78
+ ## recurse if more data to get
79
+ if r.has_key?('LastEvaluatedKey')
80
+ scan_to_file(name, r['LastEvaluatedKey'], fd)
81
+ end
79
82
  end
80
83
  end
81
84
 
85
+ desc 'scan NAME', 'scan table with NAME'
86
+ method_option :output, aliases: '-o', type: :string, default: nil, desc: 'Output filename (default: stdout)'
87
+ def scan(name, exclusive_start_key = nil)
88
+ fd = options[:output] ? File.open(options[:output], 'w') : $stdout.dup # open output file or stdout
89
+ scan_to_file(name, exclusive_start_key, fd)
90
+ fd.close
91
+ end
92
+
82
93
  desc 'put_items NAME', 'puts json items into the table with NAME'
83
94
  def put_items(name, file = nil)
84
95
  io = (file and File.open(file)) || ((not $stdin.tty?) and $stdin)
@@ -1,3 +1,3 @@
1
1
  module Awful
2
- VERSION = "0.0.50"
2
+ VERSION = "0.0.51"
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.50
4
+ version: 0.0.51
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ric Lister
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-22 00:00:00.000000000 Z
11
+ date: 2015-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler