zillabyte-cli 0.9.45 → 0.9.46

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDIxYzA1NWYzMWUwYWI1ZTE1MzRiZDNjOTkxYjNmNTlmYmVkODVkZA==
4
+ NzcxYzBiOTMxYTBjOThhOTliNzFhNzFlMGMwZDM1YjY1ZWIzMDk4Nw==
5
5
  data.tar.gz: !binary |-
6
- MTgyZTY4Mjc4MzM5OGFhODEzZTA3YjA5YWVlYzZhNDM0NTFlZDhhNw==
6
+ YjAwODliYjIzNTAxODE4N2IwNGIzNjcwYjFhOWY5NTMwYTBjZGU3OA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MWQwNTFlNjY4ODU3ZjU2MDliZjRlMWVhZDAxNjA5M2U2MThmMGY0ZWYwY2My
10
- N2NkNTgwNGI0YTI0ZGZmYTllNDUzMmI5ZTdkY2M3YzMzNzQ2Y2Y0OTA1MGE4
11
- ZGI0YzRkZmMzMDk2Y2U1ZjUxNjE2YTQwNmZkNzFjMGUwN2U0NzA=
9
+ YTU4OTg0Yjc1MGE1NWZlZTI5YTg2OTA3Y2E3OGEzZjdkZWM1ODIyODkwMGFl
10
+ ZjY1NjEwZjBkZWM1MzFlZmMxNjVmYzcxNGYyMjlhNTdkYzIwZjk1NjM2MWUz
11
+ MjE4MjE2ZDRhMTcwMzg0Nzk1OTdmMTk0NjBjNDJjNzY1OTI4YzE=
12
12
  data.tar.gz: !binary |-
13
- ZjFlNDE5OWE4NjgyMTY2NzgxOTM4M2I2NWY1NTM4ZTU3MWQ5NzM4Nzc3M2Jl
14
- Nzk3YzcwNGNjZDE1ZDQ3OTdiM2YzNmU0YmIwMzc2NzY3NjY4NzhlMmRlMjU2
15
- NDNiZjU5MDU1MmM0NGY1MDBiZjM5MGVlMmVhMTQ0MWEzOTQzNzE=
13
+ YWE2OGFjYmM3YWYxNGE4MWU3NjY3MzUyYWU4MmY2ZmRhYzViMzVmMjI0ZDg0
14
+ ZmM1ODA1ZjE4YzM0NGJkOGMxMjg2NGFiOGMwZjcwYTc4MTU4ZjE4ZWM0YTRk
15
+ YzBkNmMzZDBiMmQ2MzU5MDM4YzUxNDhhZjg0MTNjYzEwYjFiZTg=
@@ -1,5 +1,5 @@
1
1
  module Zillabyte
2
2
  module CLI
3
- VERSION = "0.9.45"
3
+ VERSION = "0.9.46"
4
4
  end
5
5
  end
@@ -291,8 +291,6 @@ class Zillabyte::Command::Data < Zillabyte::Command::Base
291
291
  error("no id given", type) if id.nil?
292
292
  error("no file given", type) if file.nil?
293
293
 
294
- file = "#{file}.gz" unless File.extname(file) == ".gz"
295
-
296
294
  res = self.api.data.pull(id, options)
297
295
 
298
296
  handle_downloading_manifest(file, res, type)
@@ -5,7 +5,7 @@ require("zillabyte/cli/base")
5
5
  class Zillabyte::Command::Download < Zillabyte::Command::Base
6
6
 
7
7
  MIN_LOCAL_JAR_VERSION = "0.0.3"
8
- LATEST_JAR_VERSION = "0.9.45"
8
+ LATEST_JAR_VERSION = "0.9.46"
9
9
  MIN_JAVA_VERSION = "1.7.0"
10
10
 
11
11
  # --local # HIDDEN
@@ -172,9 +172,32 @@ module Zillabyte
172
172
  def handle_downloading_manifest(file, res, type = nil)
173
173
  require("open-uri")
174
174
  if res["manifest"]
175
- display("writing to #{file}")
176
- File.open(file, "w") do |f|
177
- num_parts = res["manifest"].size
175
+ num_parts = res["manifest"].size
176
+ if res["decoder"].nil? or (type.nil? and res["decoder"] == "json")
177
+ require("csv")
178
+ file = "#{file}.csv" unless File.extname(file) == ".csv"
179
+ display("writing to #{file}")
180
+
181
+ f = CSV.open(file, "w")
182
+ res["manifest"].each_with_index do |uri, index|
183
+ display "\tdownloading part #{index}/#{num_parts}" unless type == "json"
184
+ open(uri) do |gz|
185
+ Zlib::GzipReader.new(gz).each_line do |line|
186
+ hash = JSON.parse(line)
187
+ values = []
188
+ res["schema"].each do |col|
189
+ values << hash[col.keys.first]
190
+ end
191
+ f << values
192
+ end
193
+ end
194
+ end
195
+ f.close
196
+ elsif type == res["decoder"] or (type.nil? and res["decoder"] == "csv")
197
+ file = "#{file}.gz" unless File.extname(file) == ".gz"
198
+ display("writing to #{file}")
199
+
200
+ f = File.open(file, "w")
178
201
  res["manifest"].each_with_index do |uri, index|
179
202
  display "\tdownloading part #{index}/#{num_parts}" unless type == "json"
180
203
  f.write open(uri).read
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zillabyte-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.45
4
+ version: 0.9.46
5
5
  platform: ruby
6
6
  authors:
7
7
  - zillabyte
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-04 00:00:00.000000000 Z
11
+ date: 2014-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake