open4ssh 0.1.0 → 0.1.1

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: 78635fba401d382c7a6cf79897cb94e89ec54175
4
- data.tar.gz: 3a33cebef1a16d8071d4dc2c7aefa849a6f60888
3
+ metadata.gz: 64411bd7946581982389a29fa49974703aaac6a4
4
+ data.tar.gz: 7dae3d9662aa2373ffd4246a3a2f4b76b7e3531b
5
5
  SHA512:
6
- metadata.gz: 0f380979bfca37db680e5bf1e0f7ba1c4966279ee5e879caafbc73216d261a48ebab5905f8641ca1c8c9acf09029d5a42420a35f55b90ff975551482f18aa5ed
7
- data.tar.gz: 0e11987f6bcdb82f4dd1c3586dade177189dfc8a6495fa89913afb8f72868ed62676c75d0f7129afb577b4b14c85b4238042da2e5d698b19d987c6e60e9f90cb
6
+ metadata.gz: 412afd60971d813b4febfbcea213f10965f25163a7ed3486c6b1b85b219d9701c3cfc7c5af91934caadd12fd7432ebe24afabc7535326732c235846ee96f9bef
7
+ data.tar.gz: d50cd2d1c3f7bf6bbfa42b6941aa6ad2f7471b3785bbc0a93c057aae5d3550477d70b4b6225f47502072030a01cfa88b433471fd2089a2351e88598a53c4978c
data/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ ## Version 0.1.1
4
+
5
+ Warning, this update is not backward compatible.
6
+
7
+ - renamed exec to capture function (better alignment to Open3)
8
+ - renamed exec3 to capture3 function (better alignment to Open3)
9
+
10
+ ## Version 0.1.0
11
+
12
+ Initial release.
13
+
14
+ - exec function
15
+ - exec3 function
data/README.md CHANGED
@@ -35,7 +35,7 @@ Or install it yourself as:
35
35
 
36
36
  ### Remote execution of a single command via SSH
37
37
 
38
- All parameters of the _exec_ command are explained [here](Open4ssh.html#exec-class_method).
38
+ All parameters of the _capture_ command are explained [here](Open4ssh.html#capture-class_method).
39
39
 
40
40
  However, the following snippets explain how to use Open4ssh.
41
41
  To execute simply one single command on a remote host, we can do the following:
@@ -43,7 +43,7 @@ To execute simply one single command on a remote host, we can do the following:
43
43
  ```ruby
44
44
  require 'open4ssh'
45
45
 
46
- stdout = Open4ssh.exec(
46
+ stdout = Open4ssh.capture(
47
47
  host: 'remote.host.io',
48
48
  user: 'nane',
49
49
  pwd: 'secret',
@@ -60,7 +60,7 @@ For a lot of cloud scenarios it is more appropriate to support a keybased login.
60
60
  ```ruby
61
61
  require 'open4ssh'
62
62
 
63
- stdout = Open4ssh.exec(
63
+ stdout = Open4ssh.capture(
64
64
  host: 'remote.host.io',
65
65
  user: 'nane',
66
66
  key: '/path/to/your/sshkey.pem',
@@ -71,7 +71,7 @@ puts stdout
71
71
 
72
72
  ### Remote execution of a sequence of commands via SSH
73
73
 
74
- All parameters of the _exec4_ command are explained [here](Open4ssh.html#exec4-class_method).
74
+ All parameters of the _capture4_ command are explained [here](Open4ssh.html#capture4-class_method).
75
75
  The following snippets will explain how to use Open4ssh to execute a (sequence) of commands.
76
76
 
77
77
  This snippet here will execute five shell commands sequentially
@@ -80,7 +80,7 @@ This snippet here will execute five shell commands sequentially
80
80
  require 'open4ssh'
81
81
  require 'pp'
82
82
 
83
- returns = Open4ssh.exec4(
83
+ returns = Open4ssh.capture4(
84
84
  host: 'remote.host.io',
85
85
  user: 'nane',
86
86
  key: '/path/to/your/sshkey.pem',
@@ -117,7 +117,7 @@ each command could be successfully processed (exit code 0). So this snippet here
117
117
  require 'open4ssh'
118
118
  require 'pp'
119
119
 
120
- returns = Open4ssh.exec4(
120
+ returns = Open4ssh.capture4(
121
121
  host: 'remote.host.io',
122
122
  user: 'nane',
123
123
  key: '/path/to/your/sshkey.pem',
@@ -146,7 +146,7 @@ Because Open4ssh only executes commands as long as they are returning a exit cod
146
146
  pragmatically whether all commands of a sequence have been executed successfully:
147
147
 
148
148
  ```ruby
149
- exit_code, stderr, stdout, command = Open4ssh.exec4(
149
+ exit_code, stderr, stdout, command = Open4ssh.capture4(
150
150
  host: 'remote.host.io',
151
151
  user: 'nane',
152
152
  key: '/path/to/your/sshkey.pem',
@@ -169,7 +169,7 @@ end
169
169
  Just a small example. Assuming your remote host is a Ubuntu 14.04 system we could do something like that:
170
170
 
171
171
  ```ruby
172
- exit_code, stdout, stderr, command = Open4ssh.exec4(
172
+ exit_code, stdout, stderr, command = Open4ssh.capture4(
173
173
  host: 'remote.host.io',
174
174
  user: 'nane',
175
175
  key: '/path/to/your/sshkey.pem',
@@ -193,7 +193,7 @@ Of course, you can do any other tasks as well. This was only one example ;-)
193
193
  If you want to know what is happening there you can turn on the verbose mode (mostly useful for debugging).
194
194
 
195
195
  ```ruby
196
- exit_code, stdout, stderr, command = Open4ssh.exec4(
196
+ exit_code, stdout, stderr, command = Open4ssh.capture4(
197
197
  host: 'remote.host.io',
198
198
  user: 'nane',
199
199
  key: '/path/to/your/sshkey.pem',
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require "bundler/gem_tasks"
2
2
  require 'yard'
3
3
 
4
4
  YARD::Rake::YardocTask.new do |t|
5
- t.files = ['lib/**/*.rb', '-', 'README.md', 'LICENSE.txt']
5
+ t.files = ['lib/**/*.rb', '-', 'README.md', 'LICENSE.txt', 'CHANGELOG.md']
6
6
  # t.options = ['--any', '--extra', '--opts']
7
7
  t.stats_options = ['--list-undoc']
8
8
  end
@@ -1,3 +1,3 @@
1
1
  module Open4ssh
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/open4ssh.rb CHANGED
@@ -3,7 +3,7 @@ require "net/ssh"
3
3
 
4
4
  module Open4ssh
5
5
 
6
- # Executes a shell command on a remote host via SSH and returns the console output.
6
+ # Executes a shell command on a remote host via SSH and captures the console output.
7
7
  #
8
8
  # @param host [String] DNS name or IP address of the remote host (required)
9
9
  # @param port [Integer] Port (defaults to 22)
@@ -14,7 +14,16 @@ module Open4ssh
14
14
  #
15
15
  # @return [String] console output of executed command (output includes stdout and stderr)
16
16
  #
17
- def self.exec(host: '', user: '', port: 22, key: '', pwd: '', cmd: '')
17
+ # @example
18
+ # stdout = Open4ssh.capture(
19
+ # host: 'remote.host.io',
20
+ # user: 'nane',
21
+ # pwd: 'secret',
22
+ # cmd: 'ls -la'
23
+ # )
24
+ # puts stdout
25
+ #
26
+ def self.capture(host: '', user: '', port: 22, key: '', pwd: '', cmd: '')
18
27
  stdout = ""
19
28
  keys = [key]
20
29
 
@@ -26,7 +35,7 @@ module Open4ssh
26
35
  return stdout
27
36
  end
28
37
 
29
- # Executes a list of shell commands on a remote host via SSH and returns their exit codes, stdouts and stderrs.
38
+ # Executes a list of shell commands on a remote host via SSH and captures their exit codes, stdouts and stderrs.
30
39
  # The commands are executed sequentially until a command terminates with an exit code not equal 0 (no success).
31
40
  #
32
41
  # @param host [String] DNS name or IP address of the remote host (required)
@@ -39,7 +48,20 @@ module Open4ssh
39
48
  #
40
49
  # @return [Array<exit_code, stdout, stderr, command>] List of exit_code, stdout, stderr and executed commands
41
50
  #
42
- def self.exec4(host: '', user: '', port: 22, key: '', pwd: '', cmd: [], verbose: false)
51
+ # @example
52
+ # exit_code, stderr, stdout, command = Open4ssh.capture4(
53
+ # host: 'remote.host.io',
54
+ # user: 'nane',
55
+ # key: '/path/to/your/sshkey.pem',
56
+ # cmd: [
57
+ # "touch helloworld.txt",
58
+ # "cat helloworld.txt",
59
+ # "echo 'Hello World' >> helloworld.txt",
60
+ # "cat helloworld.txt",
61
+ # "rm helloworld.txt"
62
+ # ]).last
63
+ #
64
+ def self.capture4(host: '', user: '', port: 22, key: '', pwd: '', cmd: [], verbose: false)
43
65
  keys = [key]
44
66
  results = []
45
67
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open4ssh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nane Kratzke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-01 00:00:00.000000000 Z
11
+ date: 2016-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -76,6 +76,7 @@ extra_rdoc_files: []
76
76
  files:
77
77
  - ".gitignore"
78
78
  - ".travis.yml"
79
+ - CHANGELOG.md
79
80
  - Gemfile
80
81
  - LICENSE.txt
81
82
  - README.md
@@ -104,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
105
  version: '0'
105
106
  requirements: []
106
107
  rubyforge_project:
107
- rubygems_version: 2.4.5.1
108
+ rubygems_version: 2.4.6
108
109
  signing_key:
109
110
  specification_version: 4
110
111
  summary: Wrapper around net-ssh for plain execution of remote shell commands.