thor-ssh 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,22 +13,14 @@ class Thor
13
13
  super(base, destination, config)
14
14
  end
15
15
 
16
- # def exists?
17
- # puts "CHECK EXISTS"
18
- # false
19
- # end
20
-
21
16
  def identical?
22
17
  # TODO: find a good way to check if these are identical, then move the file
23
18
  # into place depending on user action
24
19
  # exists? && @base.destination_files.binread(destination) == render
25
-
26
- puts "CHECK IDENTICAL"
27
20
  false
28
21
  end
29
22
 
30
23
  def render
31
- puts "RENDER: #{source}"
32
24
  @render ||= open(source) {|input| input.binmode.read }
33
25
  end
34
26
 
@@ -45,6 +45,12 @@ module ThorSsh
45
45
  def exec(command)
46
46
  return destination_server.run(command)
47
47
  end
48
+
49
+ # Similar to run, but silent and always executes on the remote server
50
+ # Also returns the stderr, exit_code, and exit_signal seperate
51
+ def exec_with_codes(command)
52
+ return destination_server.run_with_codes(command)
53
+ end
48
54
 
49
55
  def run(command, config={})
50
56
  return unless behavior == :invoke
@@ -8,6 +8,40 @@ module ThorSsh
8
8
  def initialize(connection)
9
9
  @connection = connection
10
10
  end
11
+
12
+ def run_with_codes
13
+ stdout_data = ""
14
+ stderr_data = ""
15
+ exit_code = nil
16
+ exit_signal = nil
17
+ connection.open_channel do |channel|
18
+ channel.exec(command) do |ch, success|
19
+ unless success
20
+ abort "FAILED: couldn't execute command (connection.channel.exec)"
21
+ end
22
+ channel.on_data do |ch,data|
23
+ puts data
24
+ stdout_data += data
25
+ end
26
+
27
+ channel.on_extended_data do |ch,type,data|
28
+ stderr_data += data
29
+ end
30
+
31
+ channel.on_request("exit-status") do |ch,data|
32
+ exit_code = data.read_long
33
+ end
34
+
35
+ channel.on_request("exit-signal") do |ch, data|
36
+ exit_signal = data.read_long
37
+ end
38
+ end
39
+ channel.wait
40
+ end
41
+ # connection.loop
42
+
43
+ return stdout_data, stderr_data, exit_code, exit_signal
44
+ end
11
45
 
12
46
  def run(command)
13
47
  return connection.exec!(command)
@@ -1,3 +1,3 @@
1
1
  module ThorSsh
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thor-ssh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -171,7 +171,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
171
171
  version: '0'
172
172
  segments:
173
173
  - 0
174
- hash: 1765081219719402067
174
+ hash: -3046248322099718199
175
175
  required_rubygems_version: !ruby/object:Gem::Requirement
176
176
  none: false
177
177
  requirements:
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
180
  version: '0'
181
181
  segments:
182
182
  - 0
183
- hash: 1765081219719402067
183
+ hash: -3046248322099718199
184
184
  requirements: []
185
185
  rubyforge_project:
186
186
  rubygems_version: 1.8.22