td-client 0.8.26 → 0.8.27

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,4 +1,9 @@
1
1
 
2
+ == 2012-09-17 version 0.8.27
3
+
4
+ * Added Table#estimated_storage_size_string
5
+
6
+
2
7
  == 2012-09-13 version 0.8.26
3
8
 
4
9
  * Added Account model and Table#esetimated_storage_size method
data/lib/td/client/api.rb CHANGED
@@ -158,7 +158,7 @@ class API
158
158
  js = checked_json(body, %w[account])
159
159
  a = js["account"]
160
160
  plan = a['plan'].to_i
161
- storage_size = a['storage_size'].to_f
161
+ storage_size = a['storage_size'].to_i
162
162
  return [plan, storage_size]
163
163
  end
164
164
 
@@ -223,7 +223,7 @@ class API
223
223
  count = (m['count'] || 0).to_i # TODO?
224
224
  created_at = m['created_at']
225
225
  updated_at = m['updated_at']
226
- estimated_storage_size = m['estimated_storage_size']
226
+ estimated_storage_size = m['estimated_storage_size'].to_i
227
227
  schema = JSON.parse(m['schema'] || '[]')
228
228
  result[name] = [type, schema, count, created_at, updated_at, estimated_storage_size]
229
229
  }
@@ -20,14 +20,14 @@ class Account < Model
20
20
  attr_reader :plan, :storage_size
21
21
 
22
22
  def storage_size_string
23
- s = "%.1f GB" % (@storage_size / (1024*1024*1024))
24
- if s == "0.0 GB"
25
- if @storage_size <= 1024*1024
26
- return "0.0 GB"
27
- end
23
+ if @storage_size <= 1024*1024
24
+ return "0.0 GB"
25
+ elsif @storage_size <= 60*1024*1024
28
26
  return "0.01 GB"
27
+ elsif @storage_size <= 10*1024*1024*1024
28
+ "%.1f GB" % (@storage_size.to_f / (1024*1024*1024))
29
29
  else
30
- return s
30
+ "%d GB" % (@storage_size.to_f / (1024*1024*1024)).to_i
31
31
  end
32
32
  end
33
33
  end
@@ -138,6 +138,18 @@ class Table < Model
138
138
  def export(storage_type, opts={})
139
139
  @client.export(@db_name, @table_name, storage_type, opts)
140
140
  end
141
+
142
+ def estimated_storage_size_string
143
+ if @estimated_storage_size <= 1024*1024
144
+ return "0.0 GB"
145
+ elsif @estimated_storage_size <= 60*1024*1024
146
+ return "0.01 GB"
147
+ elsif @estimated_storage_size <= 10*1024*1024*1024
148
+ "%.1f GB" % (@estimated_storage_size.to_f / (1024*1024*1024))
149
+ else
150
+ "%d GB" % (@estimated_storage_size.to_f / (1024*1024*1024)).to_i
151
+ end
152
+ end
141
153
  end
142
154
 
143
155
  class Schema
@@ -1,5 +1,5 @@
1
1
  module TreasureData
2
2
 
3
- VERSION = '0.8.26'
3
+ VERSION = '0.8.27'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: td-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.26
4
+ version: 0.8.27
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-13 00:00:00.000000000 Z
12
+ date: 2012-09-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: msgpack