houcho 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7507d97a03907ede046c497483d4b392050c9cc0
4
- data.tar.gz: 1d12b359fbb0b67fc970aeb1ff1039f0873ac9a1
3
+ metadata.gz: 3dfa40a671511626f2a5665f70339de35d40004c
4
+ data.tar.gz: 63d63e7aa834a00738aab1d6550b532149dd8100
5
5
  SHA512:
6
- metadata.gz: f8e6196a85525d9b1ab2c98fb4f8bd040262d35b8d0b34a89bf511d5536fba3f0c7a2636e6c1d25723f5ae3f72566011cefd440e44c8bc97b35e61272551d08f
7
- data.tar.gz: bcda04b358bdc47d2e2eb8231a92ae702dfaa45370a48c56cfa08a56a90e059c2253395022e9806a9dab4e29fe3390aea430ea87c31a5077614da3bfd099e459
6
+ metadata.gz: 20f31de24421b105522f7bc2e089c6d21fc3e96cb6c67649c4321b82cd9baf1b4e9318f42969b0d7a14b9f9571359ea2891212df9d29efe153e12a03ae25ba12
7
+ data.tar.gz: cb9831aa6687b2a89c3104bda38b65fb58e487e3b815c32772f724a6cb3d6911eb24ae87e2eb451ac2d3659f2ef46404577bf0f43f613acd2562a311b9e43a20
data/README.md CHANGED
@@ -145,3 +145,5 @@ $ houcho role exec studio3104::www --exclude-hosts studio3104.test
145
145
  - write more tests
146
146
  - `Houcho::Logger`
147
147
  - LTSV
148
+ - yaml -> sqlite ?
149
+ - executable spec from relative path(current directory is any)
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Houcho
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
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(['hostA'], ['studio3104'])
11
+ Host.attach('hostA', 'studio3104')
12
12
 
13
13
  File.write('spec/specA_spec.rb',' ')
14
- Spec.attach(['specA'], ['studio3104'])
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(['houcho::rspec::studio3104'], ['studio3104'])
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(['www']) }
34
- it { expect { Role.create(['www']) }.to raise_error }
35
- it { Role.delete(['www']) }
36
- it { expect { Role.delete(['web']) }.to raise_error }
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.should eq ['studio3104', 'studio3105'] }
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(['host1'], ['invalid_role']) }.to raise_error }
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(['host1'], ['invalid_role']) }.to raise_error }
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: houcho
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Satoshi SUZUKI