ztk 1.5.2 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/ztk/command.rb CHANGED
@@ -145,6 +145,8 @@ module ZTK
145
145
  end
146
146
 
147
147
  output += data
148
+
149
+ options.on_progress.nil? or options.on_progress.call
148
150
  end
149
151
  break if reader_writer_map.keys.all?{ |reader| reader.eof? }
150
152
  end
@@ -25,23 +25,27 @@ module ZTK
25
25
  # remote = File.expand_path(File.join(ENV["HOME"], ".ssh", "id_rsa.pub"))
26
26
  # ssh.download(remote, local)
27
27
  def download(remote, local, options={})
28
- config.ui.logger.debug { "config=#{config.send(:table).inspect}" }
29
- config.ui.logger.info { "download(#{remote.inspect}, #{local.inspect})" }
30
28
  options = {:recursive => ::File.directory?(local) }.merge(options)
29
+ options = OpenStruct.new(config.send(:table).merge(options))
30
+
31
+ options.ui.logger.debug { "config=#{config.send(:table).inspect}" }
32
+ options.ui.logger.debug { "options=#{options.send(:table).inspect}" }
33
+ options.ui.logger.info { "download(#{remote.inspect}, #{local.inspect})" }
31
34
 
32
35
  ZTK::RescueRetry.try(:tries => 3, :on => EOFError, :on_retry => method(:on_retry)) do
33
- sftp.download!(remote.to_s, local.to_s, options) do |event, downloader, *args|
36
+ sftp.download!(remote.to_s, local.to_s, options.send(:table)) do |event, downloader, *args|
34
37
  case event
35
38
  when :open
36
- config.ui.logger.debug { "download(#{args[0].remote} -> #{args[0].local})" }
39
+ options.ui.logger.debug { "download(#{args[0].remote} -> #{args[0].local})" }
37
40
  when :close
38
- config.ui.logger.debug { "close(#{args[0].local})" }
41
+ options.ui.logger.debug { "close(#{args[0].local})" }
39
42
  when :mkdir
40
- config.ui.logger.debug { "mkdir(#{args[0]})" }
43
+ options.ui.logger.debug { "mkdir(#{args[0]})" }
41
44
  when :get
42
- config.ui.logger.debug { "get(#{args[0].remote}, size #{args[2].size} bytes, offset #{args[1]})" }
45
+ options.ui.logger.debug { "get(#{args[0].remote}, size #{args[2].size} bytes, offset #{args[1]})" }
46
+ options.on_progress.nil? or options.on_progress.call
43
47
  when :finish
44
- config.ui.logger.debug { "finish" }
48
+ options.ui.logger.debug { "finish" }
45
49
  end
46
50
  end
47
51
  end
data/lib/ztk/ssh/exec.rb CHANGED
@@ -36,7 +36,7 @@ module ZTK
36
36
  def exec(command, options={})
37
37
  options = OpenStruct.new(config.send(:table).merge(options))
38
38
 
39
- options.ui.logger.debug { "config=#{options.send(:table).inspect}" }
39
+ options.ui.logger.debug { "config=#{config.send(:table).inspect}" }
40
40
  options.ui.logger.debug { "options=#{options.send(:table).inspect}" }
41
41
  options.ui.logger.info { "exec(#{command.inspect})" }
42
42
 
@@ -78,6 +78,8 @@ module ZTK
78
78
 
79
79
  options.ui.stdout.print(data) unless options.silence
80
80
  output += data
81
+
82
+ options.on_progress.nil? or options.on_progress.call
81
83
  end
82
84
 
83
85
  ch.on_extended_data do |c, type, data|
@@ -90,6 +92,8 @@ module ZTK
90
92
 
91
93
  options.ui.stderr.print(data) unless options.silence
92
94
  output += data
95
+
96
+ options.on_progress.nil? or options.on_progress.call
93
97
  end
94
98
 
95
99
  ch.on_request("exit-status") do |c, data|
@@ -20,23 +20,27 @@ module ZTK
20
20
  # @param [String] local The local file/path you wish to upload from.
21
21
  # @param [String] remote The remote file/path you with to upload to.
22
22
  # @return [Boolean] True if successful.
23
- def upload(local, remote)
24
- config.ui.logger.debug { "config=#{config.send(:table).inspect}" }
23
+ def upload(local, remote, options={})
24
+ options = OpenStruct.new(config.send(:table).merge(options))
25
+
26
+ options.ui.logger.debug { "config=#{config.send(:table).inspect}" }
27
+ options.ui.logger.debug { "options=#{options.send(:table).inspect}" }
25
28
  config.ui.logger.info { "upload(#{local.inspect}, #{remote.inspect})" }
26
29
 
27
30
  ZTK::RescueRetry.try(:tries => 3, :on => EOFError, :on_retry => method(:on_retry)) do
28
31
  sftp.upload!(local.to_s, remote.to_s) do |event, uploader, *args|
29
32
  case event
30
33
  when :open
31
- config.ui.logger.debug { "upload(#{args[0].local} -> #{args[0].remote})" }
34
+ options.ui.logger.debug { "upload(#{args[0].local} -> #{args[0].remote})" }
32
35
  when :close
33
- config.ui.logger.debug { "close(#{args[0].remote})" }
36
+ options.ui.logger.debug { "close(#{args[0].remote})" }
34
37
  when :mkdir
35
- config.ui.logger.debug { "mkdir(#{args[0]})" }
38
+ options.ui.logger.debug { "mkdir(#{args[0]})" }
36
39
  when :put
37
- config.ui.logger.debug { "put(#{args[0].remote}, size #{args[2].size} bytes, offset #{args[1]})" }
40
+ options.ui.logger.debug { "put(#{args[0].remote}, size #{args[2].size} bytes, offset #{args[1]})" }
41
+ options.on_progress.nil? or options.on_progress.call
38
42
  when :finish
39
- config.ui.logger.debug { "finish" }
43
+ options.ui.logger.debug { "finish" }
40
44
  end
41
45
  end
42
46
  end
data/lib/ztk/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module ZTK
2
2
 
3
3
  # ZTK Version String
4
- VERSION = "1.5.2"
4
+ VERSION = "1.5.3"
5
5
 
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ztk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -281,7 +281,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
281
281
  version: '0'
282
282
  segments:
283
283
  - 0
284
- hash: 1328731926470654880
284
+ hash: -2701900535427889660
285
285
  required_rubygems_version: !ruby/object:Gem::Requirement
286
286
  none: false
287
287
  requirements:
@@ -290,7 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
290
  version: '0'
291
291
  segments:
292
292
  - 0
293
- hash: 1328731926470654880
293
+ hash: -2701900535427889660
294
294
  requirements: []
295
295
  rubyforge_project:
296
296
  rubygems_version: 1.8.25