gazer 0.2.23 → 0.2.24

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: 3703d087e39d95150305aa414fa6a7bf8f18c6b0
4
- data.tar.gz: e3a77952ee01fd8eb78f3c89b194622800de2de9
3
+ metadata.gz: a25b9ad954b83530e3561459d1a5ca6d9bee6f3f
4
+ data.tar.gz: 31cf9c8329e387157cc7939849b590ac9c483601
5
5
  SHA512:
6
- metadata.gz: 83ae74fca0c61ee82e50f9fb7f5db945276a6c47956a1799c8ebe5b4733de8be874522af7b79d660c22d19f0ff073cfe0c9b853186ab1aaf81597367fd3573d2
7
- data.tar.gz: daf31b848eed4d29d6be094362b2178d606be3a0457660eef0fc0f47b3d84119e6d044ad1a1e65a60c2a4c08f94abf35d34eb59c614aa5241fa54b6c35391425
6
+ metadata.gz: da0eb3d49d53a4e9aca08de2128ad03ec5701ee2c9633e8752bd77e9e0c219af266256fca37158fa92785afc8f2756ee5cbe83b708a79630e1bb44af55f90531
7
+ data.tar.gz: e35d9573f74d7c1fe6fec0ae1ee5527cd62764be13015b6f36214cfaf2efa0c0e2edc8e75aaf3a583e77aa5e7daafccaad4a6287d1c2317a734cd2df2401baa6
data/Gemfile.lock CHANGED
@@ -1,10 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gazer (0.2.23)
4
+ gazer (0.2.24)
5
5
  looker-sdk (~> 0.0.6)
6
6
  netrc (~> 0.11.0)
7
7
  pastel (~> 0.7.2)
8
+ rubyzip (~> 1.3.0)
8
9
  thor (~> 0.20.0)
9
10
  tty-reader (~> 0.3.0)
10
11
  tty-table (~> 0.10.0)
@@ -13,11 +14,11 @@ PATH
13
14
  GEM
14
15
  remote: https://rubygems.org/
15
16
  specs:
16
- addressable (2.6.0)
17
- public_suffix (>= 2.0.2, < 4.0)
17
+ addressable (2.7.0)
18
+ public_suffix (>= 2.0.2, < 5.0)
18
19
  diff-lcs (1.3)
19
20
  equatable (0.5.0)
20
- faraday (0.15.4)
21
+ faraday (0.17.0)
21
22
  multipart-post (>= 1.2, < 3)
22
23
  kramdown (1.16.2)
23
24
  looker-sdk (0.0.6)
@@ -29,7 +30,7 @@ GEM
29
30
  pastel (0.7.2)
30
31
  equatable (~> 0.5.0)
31
32
  tty-color (~> 0.4.0)
32
- public_suffix (3.1.0)
33
+ public_suffix (4.0.1)
33
34
  rake (10.5.0)
34
35
  rouge (3.1.1)
35
36
  rspec (3.8.0)
@@ -45,6 +46,7 @@ GEM
45
46
  diff-lcs (>= 1.2.0, < 2.0)
46
47
  rspec-support (~> 3.8.0)
47
48
  rspec-support (3.8.0)
49
+ rubyzip (1.3.0)
48
50
  sawyer (0.8.2)
49
51
  addressable (>= 2.3.5)
50
52
  faraday (> 0.8, < 2.0)
data/gzr.gemspec CHANGED
@@ -58,6 +58,7 @@ Gem::Specification.new do |spec|
58
58
  spec.add_dependency "pastel", "~> 0.7.2"
59
59
  spec.add_dependency "thor", "~> 0.20.0"
60
60
  spec.add_dependency 'netrc', "~> 0.11.0"
61
+ spec.add_dependency 'rubyzip', "~> 1.3.0"
61
62
  spec.add_dependency 'looker-sdk', "~> 0.0.6"
62
63
 
63
64
  spec.add_development_dependency "bundler", "~> 1.16"
@@ -68,6 +68,8 @@ module Gzr
68
68
  desc: 'Tar file to store output'
69
69
  method_option :tgz, type: :string,
70
70
  desc: 'TarGZ file to store output'
71
+ method_option :zip, type: :string,
72
+ desc: 'Zip file to store output'
71
73
  def export(starting_space)
72
74
  if options[:help]
73
75
  invoke :help, ['export']
@@ -28,6 +28,7 @@ require_relative '../../modules/dashboard'
28
28
  require_relative '../../modules/filehelper'
29
29
  require 'pathname'
30
30
  require 'stringio'
31
+ require 'zip'
31
32
 
32
33
  module Gzr
33
34
  module Commands
@@ -46,26 +47,35 @@ module Gzr
46
47
  def execute(input: $stdin, output: $stdout)
47
48
  say_warning("options: #{@options.inspect}") if @options[:debug]
48
49
  with_session("3.1") do
49
- if @options[:tar] || @options[:tgz] then
50
- arc_path = Pathname.new(@options[:tgz] || @options[:tar])
50
+ if @options[:tar] || @options[:tgz] || @options[:zip] then
51
+ arc_path = Pathname.new(@options[:tgz] || @options[:tar] || @options[:zip])
51
52
  arc_path = Pathname.new(File.expand_path(@options[:dir])) + arc_path unless arc_path.absolute?
52
- f = File.open(arc_path.to_path, "wb")
53
- tarfile = StringIO.new(String.new,"w")
54
- begin
55
- tw = Gem::Package::TarWriter.new(tarfile)
56
- process_space(@space_id, tw)
57
- tw.flush
58
- tarfile.rewind
59
- if @options[:tgz]
60
- gzw = Zlib::GzipWriter.new(f)
61
- gzw.write tarfile.string
62
- gzw.close
63
- else
64
- f.write tarfile.string
53
+ if @options[:tar] || @options[:tgz]
54
+ f = File.open(arc_path.to_path, "wb")
55
+ tarfile = StringIO.new(String.new,"w") unless @options[:zip]
56
+ begin
57
+ tw = Gem::Package::TarWriter.new(tarfile)
58
+ process_space(@space_id, tw)
59
+ tw.flush
60
+ tarfile.rewind
61
+ if @options[:tgz]
62
+ gzw = Zlib::GzipWriter.new(f)
63
+ gzw.write tarfile.string
64
+ gzw.close
65
+ else
66
+ f.write tarfile.string
67
+ end
68
+ ensure
69
+ f.close
70
+ tarfile.close
71
+ end
72
+ else
73
+ z = Zip::File.new(arc_path.to_path, Zip::File::CREATE, false, continue_on_exists_proc: true)
74
+ begin
75
+ process_space(@space_id, z)
76
+ ensure
77
+ z.close
65
78
  end
66
- ensure
67
- f.close
68
- tarfile.close
69
79
  end
70
80
  else
71
81
  process_space(@space_id, @options[:dir])
@@ -28,16 +28,26 @@ module Gzr
28
28
  module FileHelper
29
29
  def write_file(file_name=nil,base_dir=nil,path=nil,output=$stdout)
30
30
  f = nil
31
- if base_dir.respond_to?(:mkdir)&& base_dir.respond_to?(:add_file) then
31
+ if base_dir.respond_to?(:mkdir)&& (base_dir.respond_to?(:add_file) || base_dir.respond_to?(:get_output_stream)) then
32
32
  if path then
33
33
  @archived_paths ||= Array.new
34
- base_dir.mkdir(path.to_path, 0755) unless @archived_paths.include?(path.to_path)
34
+ begin
35
+ base_dir.mkdir(path.to_path, 0755) unless @archived_paths.include?(path.to_path)
36
+ rescue Errno::EEXIST => e
37
+ nil
38
+ end
35
39
  @archived_paths << path.to_path
36
40
  end
37
41
  fn = Pathname.new(file_name.gsub('/',"\u{2215}"))
38
42
  fn = path + fn if path
39
- base_dir.add_file(fn.to_path, 0644) do |tf|
40
- yield tf
43
+ if base_dir.respond_to?(:add_file)
44
+ base_dir.add_file(fn.to_path, 0644) do |tf|
45
+ yield tf
46
+ end
47
+ elsif base_dir.respond_to?(:get_output_stream)
48
+ base_dir.get_output_stream(fn.to_path, 0644) do |zf|
49
+ yield zf
50
+ end
41
51
  end
42
52
  return
43
53
  end
data/lib/gzr/version.rb CHANGED
@@ -20,5 +20,5 @@
20
20
  # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  module Gzr
23
- VERSION = "0.2.23"
23
+ VERSION = "0.2.24"
24
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gazer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.23
4
+ version: 0.2.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike DeAngelo
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.11.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubyzip
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.3.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.3.0
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: looker-sdk
99
113
  requirement: !ruby/object:Gem::Requirement