specinfra 2.2.2 → 2.2.3

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: 0ee7e3575550560a4002026f928b774ac07d5147
4
- data.tar.gz: 05a56f3bda351636daf017ae8ba3bda7f1e0c40a
3
+ metadata.gz: a57b2d08f95569aeb857d6017f2e156976ba050c
4
+ data.tar.gz: 30045d3ab0a840cdca3f193c1618e7b179bd669b
5
5
  SHA512:
6
- metadata.gz: 1c2f25c85525b5ddce9b04f0f3b338ba3c2b1bdbc9aa0fdeb3f9c6e937681c57efcd7c6d9c9348ebba947e38a79e31045dab77f3653ec68b60cc2e7c503caa0c
7
- data.tar.gz: 55b9f9079421c1e268557e21a315a9024d403b609a1b1ad2bc17f482dbaf5ba3158b0a591ab343fea1c1c8234bf545a2e93868c3607b16bd9b747381288fed5c
6
+ metadata.gz: cdbd20dc2d38ad0d66e7ec84244c79fe7cbf1039bcf55c5eb626fda768916302590bb3dead630f8f87b9c0296f65bc082a361b343952274b32d8e34a9223b7a2
7
+ data.tar.gz: 513565d427cebdb3573488a371b3e7f43dead08d3a17152567cf3275ea4a19b64aa72b4499332873ae0e21b78e6d01882ff83253decbb25bc7d9009c86636a78
@@ -25,6 +25,19 @@ module Specinfra::Backend
25
25
  FileUtils.cp(from, to)
26
26
  end
27
27
 
28
+ def build_command(cmd)
29
+ shell = Specinfra.configuration.shell || '/bin/sh'
30
+ cmd = cmd.shelljoin if cmd.is_a?(Array)
31
+ cmd = "#{shell.shellescape} -c #{cmd.shellescape}"
32
+
33
+ path = Specinfra.configuration.path
34
+ if path
35
+ cmd = %Q{env PATH="#{path}" #{cmd}}
36
+ end
37
+
38
+ cmd
39
+ end
40
+
28
41
  private
29
42
  def with_env
30
43
  keys = %w[BUNDLER_EDITOR BUNDLE_BIN_PATH BUNDLE_GEMFILE
@@ -50,19 +63,6 @@ module Specinfra::Backend
50
63
  end
51
64
  end
52
65
 
53
- def build_command(cmd)
54
- shell = Specinfra.configuration.shell || '/bin/sh'
55
- cmd = cmd.shelljoin if cmd.is_a?(Array)
56
- cmd = "#{shell.shellescape} -c #{cmd.shellescape}"
57
-
58
- path = Specinfra.configuration.path
59
- if path
60
- cmd = %Q{env PATH="#{path}" #{cmd}}
61
- end
62
-
63
- cmd
64
- end
65
-
66
66
  def add_pre_command(cmd)
67
67
  if Specinfra.configuration.pre_command
68
68
  pre_cmd = build_command(Specinfra.configuration.pre_command)
@@ -21,6 +21,7 @@ module Specinfra::Backend
21
21
  end
22
22
  CommandResult.new :stdout => out, :exit_status => ret.exitstatus
23
23
  end
24
+
24
25
  def build_command(cmd)
25
26
  cmd
26
27
  end
@@ -33,11 +33,6 @@ module Specinfra::Backend
33
33
  run_command(Specinfra.command.get(:move_file, tmp, to))
34
34
  end
35
35
 
36
- private
37
- def prompt
38
- 'Password: '
39
- end
40
-
41
36
  def build_command(cmd)
42
37
  cmd = super(cmd)
43
38
  user = Specinfra.configuration.ssh_options[:user]
@@ -48,6 +43,11 @@ module Specinfra::Backend
48
43
  cmd
49
44
  end
50
45
 
46
+ private
47
+ def prompt
48
+ 'Password: '
49
+ end
50
+
51
51
  def with_env
52
52
  env = Specinfra.configuration.env || {}
53
53
  env[:LANG] ||= 'C'
@@ -1,3 +1,3 @@
1
1
  module Specinfra
2
- VERSION = "2.2.2"
2
+ VERSION = "2.2.3"
3
3
  end
@@ -4,13 +4,13 @@ describe Specinfra::Backend::Exec do
4
4
  describe '#build_command' do
5
5
  context 'with simple command' do
6
6
  it 'should escape spaces' do
7
- expect(Specinfra.backend.send(:build_command, 'test -f /etc/passwd')).to eq '/bin/sh -c test\ -f\ /etc/passwd'
7
+ expect(Specinfra.backend.build_command('test -f /etc/passwd')).to eq '/bin/sh -c test\ -f\ /etc/passwd'
8
8
  end
9
9
  end
10
10
 
11
11
  context 'with complex command' do
12
12
  it 'should escape special chars' do
13
- expect(Specinfra.backend.send(:build_command, 'test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq '/bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)'
13
+ expect(Specinfra.backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq '/bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)'
14
14
  end
15
15
  end
16
16
 
@@ -24,7 +24,7 @@ describe Specinfra::Backend::Exec do
24
24
  end
25
25
 
26
26
  it 'should use custom shell' do
27
- expect(Specinfra.backend.send(:build_command, 'test -f /etc/passwd')).to eq '/usr/local/bin/tcsh -c test\ -f\ /etc/passwd'
27
+ expect(Specinfra.backend.build_command('test -f /etc/passwd')).to eq '/usr/local/bin/tcsh -c test\ -f\ /etc/passwd'
28
28
  end
29
29
  end
30
30
 
@@ -38,7 +38,7 @@ describe Specinfra::Backend::Exec do
38
38
  end
39
39
 
40
40
  it 'should use custom shell' do
41
- expect(Specinfra.backend.send(:build_command, 'test -f /etc/passwd')).to eq '/usr/test\ \&\ spec/bin/sh -c test\ -f\ /etc/passwd'
41
+ expect(Specinfra.backend.build_command('test -f /etc/passwd')).to eq '/usr/test\ \&\ spec/bin/sh -c test\ -f\ /etc/passwd'
42
42
  end
43
43
  end
44
44
 
@@ -52,7 +52,7 @@ describe Specinfra::Backend::Exec do
52
52
  end
53
53
 
54
54
  it 'should use custom path' do
55
- expect(Specinfra.backend.send(:build_command, 'test -f /etc/passwd')).to eq 'env PATH="/opt/bin:/opt/foo/bin:$PATH" /bin/sh -c test\ -f\ /etc/passwd'
55
+ expect(Specinfra.backend.build_command('test -f /etc/passwd')).to eq 'env PATH="/opt/bin:/opt/foo/bin:$PATH" /bin/sh -c test\ -f\ /etc/passwd'
56
56
  end
57
57
  end
58
58
 
@@ -66,7 +66,7 @@ describe Specinfra::Backend::Exec do
66
66
  end
67
67
 
68
68
  it 'should use custom path' do
69
- expect(Specinfra.backend.send(:build_command, 'test -f /etc/passwd')).to eq 'env PATH="/opt/bin:/opt/test & spec/bin:$PATH" /bin/sh -c test\ -f\ /etc/passwd'
69
+ expect(Specinfra.backend.build_command('test -f /etc/passwd')).to eq 'env PATH="/opt/bin:/opt/test & spec/bin:$PATH" /bin/sh -c test\ -f\ /etc/passwd'
70
70
  end
71
71
  end
72
72
  end
@@ -13,11 +13,11 @@ describe Specinfra::Backend::Ssh do
13
13
  end
14
14
 
15
15
  it 'should not prepend sudo' do
16
- expect(Specinfra.backend.send(:build_command, 'test -f /etc/passwd')).to eq '/bin/sh -c test\ -f\ /etc/passwd'
16
+ expect(Specinfra.backend.build_command('test -f /etc/passwd')).to eq '/bin/sh -c test\ -f\ /etc/passwd'
17
17
  end
18
18
 
19
19
  it 'should escape special characters' do
20
- expect(Specinfra.backend.send(:build_command, 'test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq '/bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)'
20
+ expect(Specinfra.backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq '/bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)'
21
21
  end
22
22
  end
23
23
 
@@ -30,11 +30,11 @@ describe Specinfra::Backend::Ssh do
30
30
  end
31
31
 
32
32
  it 'should prepend sudo' do
33
- expect(Specinfra.backend.send(:build_command, 'test -f /etc/passwd')).to eq %q{sudo -p 'Password: ' /bin/sh -c test\ -f\ /etc/passwd}
33
+ expect(Specinfra.backend.build_command('test -f /etc/passwd')).to eq %q{sudo -p 'Password: ' /bin/sh -c test\ -f\ /etc/passwd}
34
34
  end
35
35
 
36
36
  it 'should escape special characters' do
37
- expect(Specinfra.backend.send(:build_command, 'test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq %q{sudo -p 'Password: ' /bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)}
37
+ expect(Specinfra.backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq %q{sudo -p 'Password: ' /bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)}
38
38
  end
39
39
  end
40
40
 
@@ -54,11 +54,11 @@ describe Specinfra::Backend::Ssh do
54
54
  end
55
55
 
56
56
  it 'command pattern 1a' do
57
- expect(Specinfra.backend.send(:build_command, 'test -f /etc/passwd')).to eq %q{/usr/local/bin/sudo -p 'Password: ' /bin/sh -c test\ -f\ /etc/passwd}
57
+ expect(Specinfra.backend.build_command('test -f /etc/passwd')).to eq %q{/usr/local/bin/sudo -p 'Password: ' /bin/sh -c test\ -f\ /etc/passwd}
58
58
  end
59
59
 
60
60
  it 'command pattern 2a' do
61
- expect(Specinfra.backend.send(:build_command, 'test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq %q{/usr/local/bin/sudo -p 'Password: ' /bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)}
61
+ expect(Specinfra.backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq %q{/usr/local/bin/sudo -p 'Password: ' /bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)}
62
62
  end
63
63
  end
64
64
 
@@ -78,16 +78,14 @@ describe Specinfra::Backend::Ssh do
78
78
  end
79
79
 
80
80
  it 'command pattern 1b' do
81
- expect(Specinfra.backend.send(:build_command, 'test -f /etc/passwd')).to eq '/bin/sh -c test\ -f\ /etc/passwd'
81
+ expect(Specinfra.backend.build_command('test -f /etc/passwd')).to eq '/bin/sh -c test\ -f\ /etc/passwd'
82
82
  end
83
83
 
84
84
  it 'command pattern 2b' do
85
- expect(Specinfra.backend.send(:build_command, 'test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq '/bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)'
85
+ expect(Specinfra.backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)')).to eq '/bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)'
86
86
  end
87
-
88
87
  end
89
88
 
90
-
91
89
  context 'with sudo on alternative path' do
92
90
  before do
93
91
  RSpec.configure do |c|
@@ -104,12 +102,12 @@ describe Specinfra::Backend::Ssh do
104
102
  end
105
103
 
106
104
  context 'command pattern 1a' do
107
- subject { Specinfra.backend.send(:build_command, 'test -f /etc/passwd') }
105
+ subject { Specinfra.backend.build_command('test -f /etc/passwd') }
108
106
  it { should eq %q{sudo -p 'Password: ' /bin/sh -c test\ -f\ /etc/passwd} }
109
107
  end
110
108
 
111
109
  context 'command pattern 2a' do
112
- subject { Specinfra.backend.send(:build_command, 'test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)') }
110
+ subject { Specinfra.backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)') }
113
111
  it { should eq %q{sudo -p 'Password: ' /bin/sh -c test\ \!\ -f\ /etc/selinux/config\ \|\|\ \(getenforce\ \|\ grep\ -i\ --\ disabled\ \&\&\ grep\ -i\ --\ \^SELINUX\=disabled\$\ /etc/selinux/config\)} }
114
112
  end
115
113
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specinfra
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-09 00:00:00.000000000 Z
11
+ date: 2014-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh