shexy 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -32,7 +32,7 @@ require 'net/scp'
32
32
  #
33
33
  module Shexy
34
34
 
35
- VERSION = '0.1'
35
+ VERSION = '0.2'
36
36
 
37
37
  @flags = {}
38
38
 
@@ -40,7 +40,7 @@ module Shexy
40
40
  def self.password; flags[:password]; end
41
41
  def self.key=(key); flags[:keys] = [File.expand_path(key)]; end
42
42
  def self.key; flags[:keys]; end
43
- def self.use_sudo; @sudo = true; end
43
+ def self.use_sudo(v=true); @sudo = v; end
44
44
  def self.sudo?; @sudo ||= false; end
45
45
 
46
46
  class << self
@@ -70,17 +70,25 @@ module Shexy
70
70
  # to implement access to stdout,stderr this way
71
71
  stdout = ""
72
72
  stderr = ""
73
+ exit_code = -1
74
+ exit_signal = -1
73
75
  ch.on_extended_data do |c2, type, data|
74
76
  # ERROR output here
75
77
  stderr << data
76
- yield stdout, stderr if block_given?
78
+ yield nil, data if block_given?
77
79
  end
78
80
  ch.on_data do |c2, data|
79
81
  stdout << data
80
- yield stdout, stderr if block_given?
82
+ yield data, nil if block_given?
81
83
  end
82
84
  ch.on_close do |c2|
83
- return stdout, stderr
85
+ return stdout, stderr, exit_code, exit_signal
86
+ end
87
+ ch.on_request("exit-status") do |c2,data|
88
+ exit_code = data.read_long
89
+ end
90
+ ch.on_request("exit-signal") do |c2, data|
91
+ exit_signal = data.read_long
84
92
  end
85
93
  end
86
94
  end
@@ -97,6 +105,12 @@ module Shexy
97
105
  # Shexy.copy_to 'source_file', 'dest_file'
98
106
  #
99
107
  def self.copy_to(*args)
108
+ opts = {}
109
+ if args.include?(:recursive)
110
+ opts = { :recursive => true }
111
+ args.delete :recursive
112
+ end
113
+
100
114
  if args.size > 2
101
115
  # First arg assumed to be foo@host.net
102
116
  @host = args[0]
@@ -113,7 +127,7 @@ module Shexy
113
127
  end
114
128
  from = File.expand_path from
115
129
  Net::SCP.start(host, user, flags) do |scp|
116
- scp.upload! from, to
130
+ scp.upload! from, to, opts
117
131
  end
118
132
  end
119
133
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shexy
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
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-07 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: net-ssh
@@ -129,12 +129,12 @@ executables: []
129
129
  extensions: []
130
130
  extra_rdoc_files:
131
131
  - LICENSE.txt
132
- - README.rdoc
132
+ - README.md
133
133
  files:
134
134
  - .document
135
135
  - Gemfile
136
136
  - LICENSE.txt
137
- - README.rdoc
137
+ - README.md
138
138
  - Rakefile
139
139
  - lib/shexy.rb
140
140
  - test/helper.rb
@@ -154,7 +154,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
154
154
  version: '0'
155
155
  segments:
156
156
  - 0
157
- hash: 518133985048816115
157
+ hash: 2098135952916495063
158
158
  required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  none: false
160
160
  requirements: