producer-core 0.2.9 → 0.2.10

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: 0288c1cd99933e1e53201413bc0d8c90a6229204
4
- data.tar.gz: 5d7aaef70745ce1b3396d775adfa94328a092151
3
+ metadata.gz: 746db32442ceec92cc0067f515e69d43c052afee
4
+ data.tar.gz: 8c3b7aaf1f0e4b6722609243204b635f1d5db6af
5
5
  SHA512:
6
- metadata.gz: 2ca8cfca02bec39f6732bf697a2d9111119864c4e7a96176fb87669f0fc5215bb8ffd319cf5e39b90fdf984fb7edb3cfe22f75200f9e464ea89a73585cb60dac
7
- data.tar.gz: 4786539f7a836eee916c4e278ba8b4206d32b5a6349c5c98e85609c638ce86b99300aa3295fab4d80e5c77cd8f8926a2fa32618beaa638b2fde8bed8c4a5011d
6
+ metadata.gz: ddfa5f0ffa6e5bd5b67f93d2c89b580ded6edc99876dad0e38daf5f2a3c0b36eb87b73cf0bb7ad97a257efaebe53a454263a81a838accf980dc87ee8bb531290
7
+ data.tar.gz: ffe69bcb350968fa1e3e97cc5ea5668efa4ac191d1e21731c7cedf797e0f9609b3a356d0441e0ec4b1bd4b3e72f910f2ba037a070edff111a4d922947a599e12
@@ -54,6 +54,7 @@ module Producer
54
54
 
55
55
  def run
56
56
  worker.process load_recipe.tasks
57
+ env.cleanup
57
58
  end
58
59
 
59
60
  def load_recipe
@@ -44,6 +44,10 @@ module Producer
44
44
  def dry_run?
45
45
  @dry_run
46
46
  end
47
+
48
+ def cleanup
49
+ remote.cleanup
50
+ end
47
51
  end
48
52
  end
49
53
  end
@@ -6,19 +6,6 @@ module Producer
6
6
  def string_to_hash(str)
7
7
  Hash[str.each_line.map { |l| l.chomp.split '=', 2 }]
8
8
  end
9
-
10
- def new_from_string(str)
11
- new string_to_hash str
12
- end
13
- end
14
-
15
- extend Forwardable
16
- def_delegators :@variables, :[], :key?
17
-
18
- attr_reader :variables
19
-
20
- def initialize(variables)
21
- @variables = variables
22
9
  end
23
10
  end
24
11
  end
@@ -2,6 +2,7 @@ module Producer
2
2
  module Core
3
3
  class Remote
4
4
  attr_reader :hostname
5
+ attr_writer :session
5
6
 
6
7
  def initialize(hostname)
7
8
  @hostname = hostname
@@ -41,7 +42,11 @@ module Producer
41
42
  end
42
43
 
43
44
  def environment
44
- Environment.new_from_string(execute 'env')
45
+ Environment.string_to_hash(execute 'env')
46
+ end
47
+
48
+ def cleanup
49
+ session.close if @session
45
50
  end
46
51
  end
47
52
  end
@@ -1,5 +1,5 @@
1
1
  module Producer
2
2
  module Core
3
- VERSION = '0.2.9'.freeze
3
+ VERSION = '0.2.10'.freeze
4
4
  end
5
5
  end
@@ -172,6 +172,11 @@ module Producer::Core
172
172
  .with([an_instance_of(Task), an_instance_of(Task)])
173
173
  cli.run
174
174
  end
175
+
176
+ it 'cleans up the env' do
177
+ expect(cli.env).to receive :cleanup
178
+ cli.run
179
+ end
175
180
  end
176
181
 
177
182
  describe '#load_recipe' do
@@ -157,5 +157,12 @@ module Producer::Core
157
157
  expect(env).to be_dry_run
158
158
  end
159
159
  end
160
+
161
+ describe '#cleanup' do
162
+ it 'cleans up the remote' do
163
+ expect(env.remote).to receive :cleanup
164
+ env.cleanup
165
+ end
166
+ end
160
167
  end
161
168
  end
@@ -3,47 +3,15 @@ require 'spec_helper'
3
3
  module Producer::Core
4
4
  class Remote
5
5
  describe Environment do
6
- let(:variables) { { 'FOO' => 'bar', 'BAZ' => 'qux' } }
7
6
  let(:string) { "FOO=bar\nBAZ=qux" }
8
7
  let(:argument) { variables }
9
- subject(:environment) { Environment.new(argument) }
10
8
 
11
9
  describe '.string_to_hash' do
12
10
  it 'converts key=value pairs separated by new lines to a hash' do
13
- expect(described_class.string_to_hash(string)).to eq variables
14
- end
15
- end
16
-
17
- describe '.new_from_string' do
18
- it 'returns a new instance with converted keys and values' do
19
- environment = described_class.new_from_string string
20
- expect(environment.variables).to eq variables
21
- end
22
- end
23
-
24
- describe '#initialize' do
25
- it 'assigns the key/value pairs' do
26
- expect(environment.variables).to eq variables
27
- end
28
- end
29
-
30
- describe '#key?' do
31
- context 'when key is defined' do
32
- it 'returns true' do
33
- expect(environment.key? 'FOO').to be true
34
- end
35
- end
36
-
37
- context 'when key is not defined' do
38
- it 'returns false' do
39
- expect(environment.key? 'INEXISTENT_KEY').to be false
40
- end
41
- end
42
- end
43
-
44
- describe '#[]' do
45
- it 'returns the value indexed by given key' do
46
- expect(environment['FOO']).to eq 'bar'
11
+ expect(described_class.string_to_hash(string)).to eq ({
12
+ 'FOO' => 'bar',
13
+ 'BAZ' => 'qux'
14
+ })
47
15
  end
48
16
  end
49
17
  end
@@ -136,5 +136,14 @@ module Producer::Core
136
136
  expect(remote.environment['FOO']).to eq 'bar'
137
137
  end
138
138
  end
139
+
140
+ describe '#cleanup' do
141
+ before { remote.session = double 'session' }
142
+
143
+ it 'closes the session' do
144
+ expect(remote.session).to receive :close
145
+ remote.cleanup
146
+ end
147
+ end
139
148
  end
140
149
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: producer-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibault Jouan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-03 00:00:00.000000000 Z
11
+ date: 2014-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh
@@ -251,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
251
251
  version: '0'
252
252
  requirements: []
253
253
  rubyforge_project:
254
- rubygems_version: 2.4.5
254
+ rubygems_version: 2.2.2
255
255
  signing_key:
256
256
  specification_version: 4
257
257
  summary: Provisioning tool