houcho 0.0.5 → 0.0.6
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/README.md +2 -0
- data/lib/houcho/element.rb +6 -0
- data/lib/houcho/role.rb +7 -0
- data/lib/houcho/version.rb +1 -1
- data/spec/houcho_spec.rb +10 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3dfa40a671511626f2a5665f70339de35d40004c
|
4
|
+
data.tar.gz: 63d63e7aa834a00738aab1d6550b532149dd8100
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20f31de24421b105522f7bc2e089c6d21fc3e96cb6c67649c4321b82cd9baf1b4e9318f42969b0d7a14b9f9571359ea2891212df9d29efe153e12a03ae25ba12
|
7
|
+
data.tar.gz: cb9831aa6687b2a89c3104bda38b65fb58e487e3b815c32772f724a6cb3d6911eb24ae87e2eb451ac2d3659f2ef46404577bf0f43f613acd2562a311b9e43a20
|
data/README.md
CHANGED
data/lib/houcho/element.rb
CHANGED
@@ -11,6 +11,9 @@ module Houcho
|
|
11
11
|
|
12
12
|
|
13
13
|
def attach(elements, roles)
|
14
|
+
elements = [elements] if elements.class == String
|
15
|
+
roles = [roles] if roles.class == String
|
16
|
+
|
14
17
|
invalid_roles = []
|
15
18
|
roles.each do |role|
|
16
19
|
index = Role.index(role)
|
@@ -29,6 +32,9 @@ module Houcho
|
|
29
32
|
|
30
33
|
|
31
34
|
def detach(elements, roles)
|
35
|
+
elements = [elements] if elements.class == String
|
36
|
+
roles = [roles] if roles.class == String
|
37
|
+
|
32
38
|
invalid_roles = []
|
33
39
|
roles.each do |role|
|
34
40
|
index = Role.index(role)
|
data/lib/houcho/role.rb
CHANGED
@@ -5,6 +5,7 @@ module Houcho
|
|
5
5
|
module_function
|
6
6
|
|
7
7
|
def create(role, exists = [])
|
8
|
+
role = [role] if role.class == String
|
8
9
|
target = role.shift
|
9
10
|
|
10
11
|
if self.index(target)
|
@@ -23,6 +24,7 @@ module Houcho
|
|
23
24
|
|
24
25
|
|
25
26
|
def delete(role, errors = {exists:[], hosts:[], specs:[], cf:[]})
|
27
|
+
role = [role] if role.class == String
|
26
28
|
target = role.shift
|
27
29
|
index = self.index(target)
|
28
30
|
del = true
|
@@ -117,5 +119,10 @@ module Houcho
|
|
117
119
|
def name(index)
|
118
120
|
@roles.data[index]
|
119
121
|
end
|
122
|
+
|
123
|
+
|
124
|
+
def exist?(role)
|
125
|
+
! self.index(role).nil?
|
126
|
+
end
|
120
127
|
end
|
121
128
|
end
|
data/lib/houcho/version.rb
CHANGED
data/spec/houcho_spec.rb
CHANGED
@@ -8,10 +8,10 @@ describe Houcho do
|
|
8
8
|
Dir.chdir(spectmp)
|
9
9
|
init_repo
|
10
10
|
Role.create(['studio3104', 'studio3105'])
|
11
|
-
Host.attach(
|
11
|
+
Host.attach('hostA', 'studio3104')
|
12
12
|
|
13
13
|
File.write('spec/specA_spec.rb',' ')
|
14
|
-
Spec.attach(
|
14
|
+
Spec.attach('specA', 'studio3104')
|
15
15
|
|
16
16
|
File.write('./role/cloudforecast/cf.yaml', <<EOD
|
17
17
|
--- #houcho
|
@@ -24,16 +24,16 @@ servers:
|
|
24
24
|
EOD
|
25
25
|
)
|
26
26
|
CloudForecast.load_yaml
|
27
|
-
CloudForecast::Role.attach(
|
27
|
+
CloudForecast::Role.attach('houcho::rspec::studio3104', 'studio3104')
|
28
28
|
end
|
29
29
|
|
30
30
|
|
31
31
|
describe Role do
|
32
32
|
context 'create and delete a role' do
|
33
|
-
it { Role.create(
|
34
|
-
it { expect { Role.create(
|
35
|
-
it { Role.delete(
|
36
|
-
it { expect { Role.delete(
|
33
|
+
it { Role.create('www') }
|
34
|
+
it { expect { Role.create('www') }.to raise_error }
|
35
|
+
it { Role.delete('www') }
|
36
|
+
it { expect { Role.delete('web') }.to raise_error }
|
37
37
|
end
|
38
38
|
|
39
39
|
context 'create and delete two roles' do
|
@@ -51,7 +51,7 @@ EOD
|
|
51
51
|
end
|
52
52
|
|
53
53
|
context 'get all roles' do
|
54
|
-
it { Role.all.
|
54
|
+
it { expect(Role.all).to eq(['studio3104', 'studio3105']) }
|
55
55
|
end
|
56
56
|
|
57
57
|
context 'get details of a role' do
|
@@ -77,9 +77,9 @@ EOD
|
|
77
77
|
describe Houcho::Host do
|
78
78
|
context 'attach and detach hosts to roles' do
|
79
79
|
it { Host.attach(['host1', 'host2'], ['studio3104', 'studio3105']) }
|
80
|
-
it { expect { Host.attach(
|
80
|
+
it { expect { Host.attach('host1', 'invalid_role') }.to raise_error }
|
81
81
|
it { Host.detach(['host1', 'host2'], ['studio3104', 'studio3105']) }
|
82
|
-
it { expect { Host.detach(
|
82
|
+
it { expect { Host.detach('host1', 'invalid_role') }.to raise_error }
|
83
83
|
end
|
84
84
|
|
85
85
|
context 'get details of a host' do
|