ztk 1.6.6 → 1.6.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,17 +29,11 @@ module ZTK
29
29
  :use_sudo => true
30
30
  }.merge(options)
31
31
 
32
- tempfile = Tempfile.new("bootstrap")
33
-
34
- local_tempfile = Tempfile.new("tempfile-local").path
32
+ local_tempfile = Tempfile.new("tempfile-local")
35
33
  remote_tempfile = ::File.join("", "tmp", ::File.basename(Tempfile.new("tempfile-remote").path))
36
34
 
37
- ::File.open(local_tempfile, 'w') do |file|
38
- file.puts(content)
39
- file.respond_to?(:flush) and file.flush
40
- end
41
-
42
- self.upload(local_tempfile, remote_tempfile)
35
+ local_tempfile.puts(content)
36
+ local_tempfile.respond_to?(:flush) and local_tempfile.flush
43
37
 
44
38
  command = Array.new
45
39
  command << %(sudo) if (options[:use_sudo] == true)
@@ -47,7 +41,16 @@ module ZTK
47
41
  command << remote_tempfile
48
42
  command = command.join(' ')
49
43
 
50
- result = self.exec(command, options)
44
+ result = nil
45
+
46
+ ZTK::RescueRetry.try(:tries => 3, :on_retry => method(:on_retry)) do
47
+ self.upload(local_tempfile, remote_tempfile)
48
+
49
+ result = self.exec(command, options)
50
+ end
51
+
52
+ local_tempfile.close!
53
+
51
54
  result
52
55
  end
53
56
 
@@ -27,7 +27,7 @@ module ZTK
27
27
  target.nil? and raise SSHError, "You must supply a target file!"
28
28
  !block_given? and raise SSHError, "You must supply a block!"
29
29
 
30
- local_tempfile = Tempfile.new("tempfile-local").path
30
+ local_tempfile = Tempfile.new("tempfile-local")
31
31
  remote_tempfile = ::File.join("", "tmp", ::File.basename(Tempfile.new("tempfile-remote").path))
32
32
 
33
33
  ::File.open(local_tempfile, 'w') do |file|
@@ -35,6 +35,9 @@ module ZTK
35
35
  file.respond_to?(:flush) and file.flush
36
36
  end
37
37
 
38
+ !block.nil? and block.call(local_tempfile)
39
+ local_tempfile.respond_to?(:flush) and local_tempfile.flush
40
+
38
41
  ZTK::RescueRetry.try(:tries => 3, :on_retry => method(:on_retry)) do
39
42
  self.upload(local_tempfile, remote_tempfile)
40
43
 
@@ -44,6 +47,8 @@ module ZTK
44
47
  chmod.nil? or self.exec(%(sudo chmod -v #{chmod} #{target}), :silence => true)
45
48
  end
46
49
 
50
+ local_tempfile.close!
51
+
47
52
  true
48
53
  end
49
54
 
@@ -1,6 +1,6 @@
1
1
  module ZTK
2
2
 
3
3
  # ZTK Version String
4
- VERSION = "1.6.6"
4
+ VERSION = "1.6.7"
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.6.6
4
+ version: 1.6.7
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: 2013-07-02 00:00:00.000000000 Z
12
+ date: 2013-07-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -275,7 +275,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
275
275
  version: '0'
276
276
  segments:
277
277
  - 0
278
- hash: 2795030245117698389
278
+ hash: 1194605774035367657
279
279
  required_rubygems_version: !ruby/object:Gem::Requirement
280
280
  none: false
281
281
  requirements:
@@ -284,7 +284,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
284
284
  version: '0'
285
285
  segments:
286
286
  - 0
287
- hash: 2795030245117698389
287
+ hash: 1194605774035367657
288
288
  requirements: []
289
289
  rubyforge_project:
290
290
  rubygems_version: 1.8.25