fulmar-shell 1.4.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fulmar/shell.rb +12 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88ce8ef3e2a814df451c45651e4a0a49b6692e8a
|
4
|
+
data.tar.gz: b6edafdcd35b1c425df302ada29080e617b1ebc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f23e524956f89d7183847ea181708792206a3e3eeec2dd802ea4f17e1626e397ef246276eed0be581873fcf04104222fb1d0c0ee98f13bb462439e6e138254c4
|
7
|
+
data.tar.gz: 1d13cb867c913cc1cdfee160dbaaea532b9df8cdad730596c696c69324cf789a22bd1b0214bfa77a7fd6356681d034d3e56761c4bc4a070a92db28671f85b46a
|
data/lib/fulmar/shell.rb
CHANGED
@@ -5,7 +5,7 @@ require 'open3'
|
|
5
5
|
module Fulmar
|
6
6
|
# Implements simple access to shell commands
|
7
7
|
class Shell
|
8
|
-
VERSION = '1.
|
8
|
+
VERSION = '1.5.1'
|
9
9
|
|
10
10
|
attr_accessor :debug, :last_output, :last_error, :quiet, :strict
|
11
11
|
attr_reader :path
|
@@ -33,16 +33,18 @@ module Fulmar
|
|
33
33
|
path = @path
|
34
34
|
end
|
35
35
|
|
36
|
+
options[:error_message] ||= 'Last shell command returned an error.'
|
37
|
+
|
36
38
|
command.unshift "cd #{path}"
|
37
39
|
|
38
40
|
# invoke a login shell?
|
39
|
-
shell_command = options[:login] ?
|
41
|
+
shell_command = options[:login] ? clean_environment : 'bash -c'
|
40
42
|
|
41
43
|
if local?
|
42
|
-
execute("#{shell_command} '#{escape_for_sh(command.join(' && '))}'")
|
44
|
+
execute("#{shell_command} '#{escape_for_sh(command.join(' && '))}'", options[:error_message])
|
43
45
|
else
|
44
46
|
remote_command = escape_for_sh("#{shell_command} '#{escape_for_sh(command.join(' && '))}'")
|
45
|
-
execute("ssh #{@host} '#{remote_command}'")
|
47
|
+
execute("ssh #{@host} '#{remote_command}'", options[:error_message])
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
@@ -56,8 +58,12 @@ module Fulmar
|
|
56
58
|
|
57
59
|
protected
|
58
60
|
|
61
|
+
def clean_environment
|
62
|
+
"env -i HOME=\"#{ENV['HOME']}\" bash -lc"
|
63
|
+
end
|
64
|
+
|
59
65
|
# Run the command and capture the output
|
60
|
-
def execute(command)
|
66
|
+
def execute(command, error_message)
|
61
67
|
# Ladies and gentleman: More debug, please!
|
62
68
|
puts command if @debug
|
63
69
|
|
@@ -75,7 +81,7 @@ module Fulmar
|
|
75
81
|
|
76
82
|
if @strict and wait_thr.value != 0
|
77
83
|
dump_error_message(command)
|
78
|
-
fail
|
84
|
+
fail error_message
|
79
85
|
end
|
80
86
|
|
81
87
|
wait_thr.value == 0
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fulmar-shell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerrit Visscher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|