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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fulmar/shell.rb +12 -6
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d7ee1f834b78193c9007227b8388222fcf4a7f24
4
- data.tar.gz: 82d0f09080b98ac7c8be68671ec3119ebf7f88f9
3
+ metadata.gz: 88ce8ef3e2a814df451c45651e4a0a49b6692e8a
4
+ data.tar.gz: b6edafdcd35b1c425df302ada29080e617b1ebc9
5
5
  SHA512:
6
- metadata.gz: eabf95f05e15df887b532fa5f75018767ea6b05a30d4bb8a6a06d2eb7ae726f663418a0f9c51a878d5b39231344dc5c5dabd2eae1fbef66a80c10f00752231b2
7
- data.tar.gz: 2570d005d648dc7089286478460abc27807f204c25c3eb32322e75072bb3e42c96cfc2c72c9604dbb15d8952acaf0aa7d95d9666d5b8c3f910ed4e998e881bdb
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.4.0'
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] ? 'env -i bash -lc' : 'bash -c'
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 'Last shell command returned an error.'
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.0
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-25 00:00:00.000000000 Z
11
+ date: 2015-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler