jossh 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 +4 -4
- data/lib/jossh/command_runner.rb +17 -9
- data/lib/jossh/output_handler.rb +5 -3
- data/lib/jossh/version.rb +1 -1
- metadata +29 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15cd40420f857c0961001c61dab3d683f89c907a
|
4
|
+
data.tar.gz: 884df776481c6aca398241d303fa6a58aceb3b80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dab42099d80d7d3aff945323a136cdd6078d244c7b2dceaf4e8c36e104ed7cb44300a0f7fb06c926643761e7a0e5f54daed53df8a95e78c3dbd69d09d269706f
|
7
|
+
data.tar.gz: 13a3af70813a58a68dec6784389c48beee274a41655a60c5fcdb5e9acc3427b6fd94af16d5e315a38367aa686357d8eac5760e1392cdfad8a03a76f12b5805c9
|
data/lib/jossh/command_runner.rb
CHANGED
@@ -17,15 +17,15 @@ module Jossh
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def ssh(hostspec, script, callback: nil)
|
20
|
-
callback ||= method :
|
20
|
+
callback ||= method :simple_puts
|
21
21
|
script = script.join "\n" if script.is_a? Array
|
22
22
|
hostspec = load_spec(hostspec) if hostspec.is_a? Symbol
|
23
23
|
host = hostspec.delete :host
|
24
24
|
user = hostspec.delete :user
|
25
25
|
|
26
26
|
Net::SSH.start( host, user, hostspec ) do |ssh|
|
27
|
-
ssh.exec! script do |_ch,
|
28
|
-
callback.call data
|
27
|
+
ssh.exec! script do |_ch, stream, data|
|
28
|
+
callback.call data, stream
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -40,12 +40,24 @@ module Jossh
|
|
40
40
|
|
41
41
|
def ssh_hostfile(file)
|
42
42
|
@hostfile = file
|
43
|
+
|
44
|
+
# force reload in case we were called after some ssh call was
|
45
|
+
# initiated (e.g. in tests...)
|
46
|
+
@ssh_hosts = nil
|
43
47
|
end
|
44
48
|
|
45
49
|
private
|
46
50
|
|
51
|
+
def simple_puts(data, stream)
|
52
|
+
if stream == :stderr
|
53
|
+
STDERR.puts data
|
54
|
+
else
|
55
|
+
puts data
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
47
59
|
def load_spec(key)
|
48
|
-
ssh_hosts[key] or
|
60
|
+
ssh_hosts[key] or raise "Cannot find :#{key} in #{hostfile}"
|
49
61
|
end
|
50
62
|
|
51
63
|
def ssh_hosts
|
@@ -53,7 +65,7 @@ module Jossh
|
|
53
65
|
end
|
54
66
|
|
55
67
|
def load_ssh_hosts
|
56
|
-
File.exist? hostfile or
|
68
|
+
File.exist? hostfile or raise "Cannot find #{hostfile}"
|
57
69
|
YAML.load_file hostfile
|
58
70
|
end
|
59
71
|
|
@@ -61,10 +73,6 @@ module Jossh
|
|
61
73
|
@hostfile ||= 'ssh_hosts.yml'
|
62
74
|
end
|
63
75
|
|
64
|
-
def hostfile=(file)
|
65
|
-
@hostfile = file
|
66
|
-
end
|
67
|
-
|
68
76
|
def load_script(script)
|
69
77
|
File.read script
|
70
78
|
end
|
data/lib/jossh/output_handler.rb
CHANGED
@@ -22,11 +22,13 @@ module Jossh
|
|
22
22
|
# ==== Credits:
|
23
23
|
# This function was inspired by Heroku and based on code from Mina[https://github.com/mina-deploy/mina/blob/master/lib/mina/output_helpers.rb]
|
24
24
|
#
|
25
|
-
def pretty_puts(lines)
|
25
|
+
def pretty_puts(lines, stream=nil)
|
26
26
|
lines = lines.split("\n") if lines.is_a? String
|
27
27
|
lines.each do |line|
|
28
|
-
line = line.rstrip.gsub
|
29
|
-
if
|
28
|
+
line = line.rstrip.gsub(/\t/, " ")
|
29
|
+
if stream == :stderr
|
30
|
+
puts_stderr line
|
31
|
+
elsif line =~ /^\-+> (.*?)$/
|
30
32
|
puts_status $1
|
31
33
|
elsif line =~ /^! (.*?)$/
|
32
34
|
puts_error $1
|
data/lib/jossh/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jossh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
@@ -80,6 +80,34 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '10.4'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '10.4'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.10'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.10'
|
83
111
|
description: Jossh is a wrapper around Ruby Net::SSH with a simpler interface and
|
84
112
|
prettier output
|
85
113
|
email: db@dannyben.com
|