specinfra 2.0.0.beta14 → 2.0.0.beta15
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/specinfra.rb +5 -0
- data/lib/specinfra/backend/base.rb +3 -15
- data/lib/specinfra/command/processor.rb +9 -13
- data/lib/specinfra/configuration.rb +1 -0
- data/lib/specinfra/helper.rb +0 -3
- data/lib/specinfra/helper/os.rb +1 -1
- data/lib/specinfra/runner.rb +5 -1
- data/lib/specinfra/version.rb +1 -1
- data/spec/backend/exec/build_command_spec.rb +9 -11
- data/spec/backend/exec/env_spec.rb +2 -2
- data/spec/backend/ssh/build_command_spec.rb +11 -11
- data/spec/spec_helper.rb +1 -1
- metadata +2 -5
- data/lib/specinfra/helper/backend.rb +0 -27
- data/spec/helper/backend_spec.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52cbcd87131d03d42e7afa46dbdc4fcc4d249352
|
4
|
+
data.tar.gz: f77e622fc12d536070800b2ed9ffcb9073aa2c9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cd425df44198ad44995b4b1b4fed47f36297bde6e208abedce59aed7f3b34a0889fc94b13514befc87e59edcb187400b3b29a28ce6c185f9c10f1f7eea42ecd
|
7
|
+
data.tar.gz: a2f79a8bdfe210b9050f9e3560156ee1d28bb6eff02e20714f6ae901a6912ac64699bb1d2beafbccf44d7d56a3e5e4fc28b453e7156a0f0d7851d62b8fc3d761
|
data/lib/specinfra.rb
CHANGED
@@ -7,31 +7,19 @@ module Specinfra
|
|
7
7
|
class Base
|
8
8
|
include Singleton
|
9
9
|
|
10
|
-
def set_commands(c)
|
11
|
-
@commands = c
|
12
|
-
end
|
13
|
-
|
14
10
|
def set_example(e)
|
15
11
|
@example = e
|
16
12
|
end
|
17
13
|
|
18
|
-
def commands
|
19
|
-
@commands
|
20
|
-
end
|
21
|
-
|
22
14
|
def check_zero(cmd, *args)
|
23
15
|
run_command(Specinfra.command.send(cmd, *args)).success?
|
24
16
|
end
|
25
17
|
|
26
18
|
def method_missing(meth, *args, &block)
|
27
|
-
if
|
28
|
-
|
29
|
-
backend.check_zero(meth, *args)
|
30
|
-
else
|
31
|
-
backend.run_command(Specinfra.command.send(meth, *args))
|
32
|
-
end
|
19
|
+
if meth.to_s =~ /^check/
|
20
|
+
check_zero(meth, *args)
|
33
21
|
else
|
34
|
-
Specinfra
|
22
|
+
run_command(Specinfra.command.send(meth, *args))
|
35
23
|
end
|
36
24
|
end
|
37
25
|
end
|
@@ -1,15 +1,11 @@
|
|
1
1
|
module Specinfra::Command
|
2
2
|
class Processor
|
3
3
|
def self.method_missing(meth, *args, &block)
|
4
|
-
|
5
|
-
backend.check_zero(meth, *args)
|
6
|
-
else
|
7
|
-
backend.run_command(Specinfra.command.send(meth, *args))
|
8
|
-
end
|
4
|
+
Specinfra.backend.send(meth, *args)
|
9
5
|
end
|
10
6
|
|
11
7
|
def self.check_service_is_running(service)
|
12
|
-
ret = backend.run_command(Specinfra.command.check_service_is_running(service))
|
8
|
+
ret = Specinfra.backend.run_command(Specinfra.command.check_service_is_running(service))
|
13
9
|
|
14
10
|
# In Ubuntu, some services are under upstart and "service foo status" returns
|
15
11
|
# exit status 0 even though they are stopped.
|
@@ -18,14 +14,14 @@ module Specinfra::Command
|
|
18
14
|
|
19
15
|
# If the service is not registered, check by ps command
|
20
16
|
if ret.exit_status == 1
|
21
|
-
ret = backend.run_command(Specinfra.command.check_process_is_running(service))
|
17
|
+
ret = Specinfra.backend.run_command(Specinfra.command.check_process_is_running(service))
|
22
18
|
end
|
23
19
|
|
24
20
|
ret.success?
|
25
21
|
end
|
26
22
|
|
27
23
|
def self.check_service_is_monitored_by_monit(process)
|
28
|
-
ret = backend.run_command(Specinfra.command.check_service_is_monitored_by_monit(process))
|
24
|
+
ret = Specinfra.backend.run_command(Specinfra.command.check_service_is_monitored_by_monit(process))
|
29
25
|
return false unless ret.stdout != nil && ret.success?
|
30
26
|
|
31
27
|
retlines = ret.stdout.split(/[\r\n]+/).map(&:strip)
|
@@ -36,7 +32,7 @@ module Specinfra::Command
|
|
36
32
|
end
|
37
33
|
|
38
34
|
def self.check_file_is_readable(file, by_whom)
|
39
|
-
mode = sprintf('%04s',backend.run_command(Specinfra.command.get_file_mode(file)).stdout.strip)
|
35
|
+
mode = sprintf('%04s',Specinfra.backend.run_command(Specinfra.command.get_file_mode(file)).stdout.strip)
|
40
36
|
mode = mode.split('')
|
41
37
|
mode_octal = mode[0].to_i * 512 + mode[1].to_i * 64 + mode[2].to_i * 8 + mode[3].to_i * 1
|
42
38
|
case by_whom
|
@@ -52,7 +48,7 @@ module Specinfra::Command
|
|
52
48
|
end
|
53
49
|
|
54
50
|
def self.check_file_is_writable(file, by_whom)
|
55
|
-
mode = sprintf('%04s',backend.run_command(Specinfra.command.get_file_mode(file)).stdout.strip)
|
51
|
+
mode = sprintf('%04s',Specinfra.backend.run_command(Specinfra.command.get_file_mode(file)).stdout.strip)
|
56
52
|
mode = mode.split('')
|
57
53
|
mode_octal = mode[0].to_i * 512 + mode[1].to_i * 64 + mode[2].to_i * 8 + mode[3].to_i * 1
|
58
54
|
case by_whom
|
@@ -68,7 +64,7 @@ module Specinfra::Command
|
|
68
64
|
end
|
69
65
|
|
70
66
|
def self.check_file_is_executable(file, by_whom)
|
71
|
-
mode = sprintf('%04s',backend.run_command(Specinfra.command.get_file_mode(file)).stdout.strip)
|
67
|
+
mode = sprintf('%04s',Specinfra.backend.run_command(Specinfra.command.get_file_mode(file)).stdout.strip)
|
72
68
|
mode = mode.split('')
|
73
69
|
mode_octal = mode[0].to_i * 512 + mode[1].to_i * 64 + mode[2].to_i * 8 + mode[3].to_i * 1
|
74
70
|
case by_whom
|
@@ -84,7 +80,7 @@ module Specinfra::Command
|
|
84
80
|
end
|
85
81
|
|
86
82
|
def self.check_file_is_mounted(path, expected_attr, only_with)
|
87
|
-
ret = backend.run_command(Specinfra.command.check_file_is_mounted(path))
|
83
|
+
ret = Specinfra.backend.run_command(Specinfra.command.check_file_is_mounted(path))
|
88
84
|
if expected_attr.nil? || ret.failure?
|
89
85
|
return ret.success?
|
90
86
|
end
|
@@ -118,7 +114,7 @@ module Specinfra::Command
|
|
118
114
|
|
119
115
|
def self.check_routing_table_has_entry(expected_attr)
|
120
116
|
return false if ! expected_attr[:destination]
|
121
|
-
ret = backend.get_routing_table_entry(expected_attr[:destination])
|
117
|
+
ret = Specinfra.backend.get_routing_table_entry(expected_attr[:destination])
|
122
118
|
return false if ret.failure?
|
123
119
|
|
124
120
|
ret.stdout.gsub!(/\r\n/, "\n")
|
data/lib/specinfra/helper.rb
CHANGED
data/lib/specinfra/helper/os.rb
CHANGED
data/lib/specinfra/runner.rb
CHANGED
@@ -2,7 +2,11 @@ module Specinfra
|
|
2
2
|
class Runner
|
3
3
|
include Singleton
|
4
4
|
def method_missing(meth, *args, &block)
|
5
|
-
|
5
|
+
if os.include?(:family) && os[:family] == 'windows'
|
6
|
+
Specinfra.backend.send(meth, *args)
|
7
|
+
else
|
8
|
+
Specinfra::Command::Processor.send(meth, *args)
|
9
|
+
end
|
6
10
|
end
|
7
11
|
end
|
8
12
|
end
|
data/lib/specinfra/version.rb
CHANGED
@@ -1,18 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
include Specinfra::Helper::Exec
|
4
|
-
|
5
3
|
describe Specinfra::Backend::Exec do
|
6
4
|
describe '#build_command' do
|
7
5
|
context 'with simple command' do
|
8
6
|
it 'should escape spaces' do
|
9
|
-
expect(backend.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'
|
10
8
|
end
|
11
9
|
end
|
12
10
|
|
13
11
|
context 'with complex command' do
|
14
12
|
it 'should escape special chars' do
|
15
|
-
expect(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\)'
|
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\)'
|
16
14
|
end
|
17
15
|
end
|
18
16
|
|
@@ -26,7 +24,7 @@ describe Specinfra::Backend::Exec do
|
|
26
24
|
end
|
27
25
|
|
28
26
|
it 'should use custom shell' do
|
29
|
-
expect(backend.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'
|
30
28
|
end
|
31
29
|
end
|
32
30
|
|
@@ -40,7 +38,7 @@ describe Specinfra::Backend::Exec do
|
|
40
38
|
end
|
41
39
|
|
42
40
|
it 'should use custom shell' do
|
43
|
-
expect(backend.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'
|
44
42
|
end
|
45
43
|
end
|
46
44
|
|
@@ -54,7 +52,7 @@ describe Specinfra::Backend::Exec do
|
|
54
52
|
end
|
55
53
|
|
56
54
|
it 'should use custom path' do
|
57
|
-
expect(backend.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'
|
58
56
|
end
|
59
57
|
end
|
60
58
|
|
@@ -68,7 +66,7 @@ describe Specinfra::Backend::Exec do
|
|
68
66
|
end
|
69
67
|
|
70
68
|
it 'should use custom path' do
|
71
|
-
expect(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'
|
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'
|
72
70
|
end
|
73
71
|
end
|
74
72
|
end
|
@@ -83,7 +81,7 @@ describe 'os' do
|
|
83
81
|
context 'test ubuntu with lsb_release command' do
|
84
82
|
subject { os }
|
85
83
|
it do
|
86
|
-
expect(backend).to receive(:run_command).at_least(1).times do |args|
|
84
|
+
expect(Specinfra.backend).to receive(:run_command).at_least(1).times do |args|
|
87
85
|
if ['ls /etc/debian_version', 'lsb_release -ir'].include? args
|
88
86
|
double(
|
89
87
|
:run_command_response,
|
@@ -103,7 +101,7 @@ describe 'os' do
|
|
103
101
|
context 'test ubuntu with /etc/lsb-release' do
|
104
102
|
subject { os }
|
105
103
|
it do
|
106
|
-
expect(backend).to receive(:run_command).at_least(1).times do |args|
|
104
|
+
expect(Specinfra.backend).to receive(:run_command).at_least(1).times do |args|
|
107
105
|
if ['ls /etc/debian_version', 'cat /etc/lsb-release'].include? args
|
108
106
|
double(
|
109
107
|
:run_command_response,
|
@@ -128,7 +126,7 @@ EOF
|
|
128
126
|
context 'test debian (no lsb_release or lsb-release)' do
|
129
127
|
subject { os }
|
130
128
|
it do
|
131
|
-
expect(backend).to receive(:run_command).at_least(1).times do |args|
|
129
|
+
expect(Specinfra.backend).to receive(:run_command).at_least(1).times do |args|
|
132
130
|
if args == 'ls /etc/debian_version'
|
133
131
|
double :run_command_response, :success? => true, :stdout => nil
|
134
132
|
elsif args == 'uname -m'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe backend.run_command('echo $LANG').stdout.strip do
|
3
|
+
describe Specinfra.backend.run_command('echo $LANG').stdout.strip do
|
4
4
|
it { should eq 'C' }
|
5
5
|
end
|
6
6
|
|
@@ -9,7 +9,7 @@ describe do
|
|
9
9
|
ENV['LANG'] = 'C'
|
10
10
|
set :env, :LANG => 'ja_JP.UTF-8'
|
11
11
|
end
|
12
|
-
let(:lang) { backend.run_command('echo $LANG').stdout.strip }
|
12
|
+
let(:lang) { Specinfra.backend.run_command('echo $LANG').stdout.strip }
|
13
13
|
it { expect(lang).to eq 'ja_JP.UTF-8' }
|
14
14
|
it { expect(ENV['LANG']).to eq 'C' }
|
15
15
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
3
|
+
set :backend, :ssh
|
4
4
|
|
5
5
|
describe Specinfra::Backend::Ssh do
|
6
6
|
describe '#build_command' do
|
@@ -13,11 +13,11 @@ describe Specinfra::Backend::Ssh do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'should not prepend sudo' do
|
16
|
-
expect(backend.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(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\)'
|
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(backend.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(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\)}
|
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(backend.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(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\)}
|
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,11 +78,11 @@ describe Specinfra::Backend::Ssh do
|
|
78
78
|
end
|
79
79
|
|
80
80
|
it 'command pattern 1b' do
|
81
|
-
expect(backend.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(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\)'
|
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
87
|
|
88
88
|
end
|
@@ -104,12 +104,12 @@ describe Specinfra::Backend::Ssh do
|
|
104
104
|
end
|
105
105
|
|
106
106
|
context 'command pattern 1a' do
|
107
|
-
subject { backend.build_command('test -f /etc/passwd') }
|
107
|
+
subject { Specinfra.backend.build_command('test -f /etc/passwd') }
|
108
108
|
it { should eq %q{sudo -p 'Password: ' /bin/sh -c test\ -f\ /etc/passwd} }
|
109
109
|
end
|
110
110
|
|
111
111
|
context 'command pattern 2a' do
|
112
|
-
subject { backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)') }
|
112
|
+
subject { Specinfra.backend.build_command('test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)') }
|
113
113
|
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
114
|
end
|
115
115
|
end
|
data/spec/spec_helper.rb
CHANGED
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.0.0.
|
4
|
+
version: 2.0.0.beta15
|
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-
|
11
|
+
date: 2014-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|
@@ -283,7 +283,6 @@ files:
|
|
283
283
|
- lib/specinfra/command_result.rb
|
284
284
|
- lib/specinfra/configuration.rb
|
285
285
|
- lib/specinfra/helper.rb
|
286
|
-
- lib/specinfra/helper/backend.rb
|
287
286
|
- lib/specinfra/helper/configuration.rb
|
288
287
|
- lib/specinfra/helper/detect_os.rb
|
289
288
|
- lib/specinfra/helper/detect_os/aix.rb
|
@@ -315,7 +314,6 @@ files:
|
|
315
314
|
- spec/command/redhat/interface_spec.rb
|
316
315
|
- spec/command/redhat/package_spec.rb
|
317
316
|
- spec/configuration_spec.rb
|
318
|
-
- spec/helper/backend_spec.rb
|
319
317
|
- spec/helper/os_spec.rb
|
320
318
|
- spec/helper/properties_spec.rb
|
321
319
|
- spec/helper/set_spec.rb
|
@@ -356,7 +354,6 @@ test_files:
|
|
356
354
|
- spec/command/redhat/interface_spec.rb
|
357
355
|
- spec/command/redhat/package_spec.rb
|
358
356
|
- spec/configuration_spec.rb
|
359
|
-
- spec/helper/backend_spec.rb
|
360
357
|
- spec/helper/os_spec.rb
|
361
358
|
- spec/helper/properties_spec.rb
|
362
359
|
- spec/helper/set_spec.rb
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Specinfra
|
2
|
-
module Helper
|
3
|
-
['Exec', 'Ssh', 'Cmd', 'Docker', 'WinRM', 'ShellScript', 'Dockerfile', 'Lxc'].each do |type|
|
4
|
-
eval <<-EOF
|
5
|
-
module #{type}
|
6
|
-
def backend(commands_object=nil)
|
7
|
-
if ! respond_to?(:commands)
|
8
|
-
commands_object = Specinfra::Command::Base.new
|
9
|
-
end
|
10
|
-
instance = Specinfra::Backend::#{type}.instance
|
11
|
-
instance.set_commands(commands_object || commands)
|
12
|
-
instance
|
13
|
-
end
|
14
|
-
end
|
15
|
-
EOF
|
16
|
-
end
|
17
|
-
|
18
|
-
module Backend
|
19
|
-
def backend_for(type)
|
20
|
-
instance = self.class.const_get('Specinfra').const_get('Backend').const_get(type.to_s.capitalize).instance
|
21
|
-
commands = Specinfra::Command::Base.new
|
22
|
-
instance.set_commands(commands)
|
23
|
-
instance
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/spec/helper/backend_spec.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'backend_for(:type) returns correct backend object' do
|
4
|
-
before do
|
5
|
-
RSpec.configure do |c|
|
6
|
-
c.ssh = double(:ssh, :options => { :user => 'root' })
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'backend_for(:exec) returns Specinfra::Backend::Exec' do
|
11
|
-
expect(backend_for(:exec)).to be_an_instance_of Specinfra::Backend::Exec
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'backend_for(:ssh) returns Specinfra::Backend::Ssh' do
|
15
|
-
expect(backend_for(:ssh)).to be_an_instance_of Specinfra::Backend::Ssh
|
16
|
-
end
|
17
|
-
end
|