sdbcli 1.2.5 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README +12 -0
  2. data/bin/sdbcli +1 -1
  3. data/lib/sdbcli/sdb-client.rb +14 -2
  4. metadata +1 -1
data/README CHANGED
@@ -25,6 +25,7 @@ https://bitbucket.org/winebarrel/sdbcli
25
25
  --export=DOMAIN,FILE
26
26
  --retry=NUM
27
27
  --retry-interval=SECOND
28
+ --require=FILE_LIST
28
29
  shell> export AWS_ACCESS_KEY_ID='...'
29
30
  shell> export AWS_SECRET_ACCESS_KEY='...'
30
31
  shell> export SDB_ENDPOINT='sdb.ap-northeast-1.amazonaws.com' # or SDB_REGION=ap-northeast-1
@@ -153,7 +154,18 @@ If '-' is specified as a file name, the input/output of data will become a stand
153
154
  - 1994
154
155
  - 1988
155
156
  # 3 rows in set
157
+
156
158
  ap-northeast-1> select * from employees limit 3 | hire_date.to_f.avg;
157
159
  --- 1991.0
160
+
161
+ ap-northeast-1> select * from employees | select {|i| i.first_name =~ /^C/ }.map {|i| Time.parse(i.birth_date).mon }.inject({}) {|r, i| r[i] ||= 0 \; r[i] += 1\; r }.sort_by {|k,v| k };
162
+ ---
163
+ - [1, 1]
164
+ - [3, 1]
165
+ - [5, 1]
166
+ - [8, 2]
167
+ - [10, 1]
168
+ - [12, 3]
169
+ # 6 rows in set
158
170
 
159
171
  'sum' method and 'avg' method are added to Array class.
data/bin/sdbcli CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
3
3
 
4
- Version = '1.2.5'
4
+ Version = '1.3.0'
5
5
  HISTORY_FILE = File.join((ENV['HOME'] || ENV['USERPROFILE'] || '.'), '.sdbcli_history')
6
6
  HISTSIZE = 500
7
7
  SELECT_LIMIT = 2500
@@ -3,6 +3,8 @@ require 'base64'
3
3
  require 'net/https'
4
4
  require 'openssl'
5
5
  require 'nokogiri'
6
+ require 'stringio'
7
+ require 'zlib'
6
8
 
7
9
  module SimpleDB
8
10
  class Error < StandardError; end
@@ -100,13 +102,23 @@ module SimpleDB
100
102
  doc = https.start do |w|
101
103
  req = Net::HTTP::Post.new('/',
102
104
  'Host' => @endpoint,
103
- 'Content-Type' => 'application/x-www-form-urlencoded'
105
+ 'Content-Type' => 'application/x-www-form-urlencoded',
106
+ 'Accept-Encoding' => 'gzip'
104
107
  )
105
108
 
106
109
  req.set_form_data(params)
107
110
  res = w.request(req)
111
+ body = nil
108
112
 
109
- Nokogiri::XML(res.body)
113
+ if res['Content-Encoding'] == 'gzip'
114
+ StringIO.open(res.body, 'rb') do |f|
115
+ body = Zlib::GzipReader.wrap(f).read
116
+ end
117
+ else
118
+ body = res.bod
119
+ end
120
+
121
+ Nokogiri::XML(body)
110
122
  end
111
123
 
112
124
  validate(doc)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdbcli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: