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 +4 -4
- data/lib/producer/core/cli.rb +1 -0
- data/lib/producer/core/env.rb +4 -0
- data/lib/producer/core/remote/environment.rb +0 -13
- data/lib/producer/core/remote.rb +6 -1
- data/lib/producer/core/version.rb +1 -1
- data/spec/producer/core/cli_spec.rb +5 -0
- data/spec/producer/core/env_spec.rb +7 -0
- data/spec/producer/core/remote/environment_spec.rb +4 -36
- data/spec/producer/core/remote_spec.rb +9 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 746db32442ceec92cc0067f515e69d43c052afee
|
4
|
+
data.tar.gz: 8c3b7aaf1f0e4b6722609243204b635f1d5db6af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddfa5f0ffa6e5bd5b67f93d2c89b580ded6edc99876dad0e38daf5f2a3c0b36eb87b73cf0bb7ad97a257efaebe53a454263a81a838accf980dc87ee8bb531290
|
7
|
+
data.tar.gz: ffe69bcb350968fa1e3e97cc5ea5668efa4ac191d1e21731c7cedf797e0f9609b3a356d0441e0ec4b1bd4b3e72f910f2ba037a070edff111a4d922947a599e12
|
data/lib/producer/core/cli.rb
CHANGED
data/lib/producer/core/env.rb
CHANGED
@@ -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
|
data/lib/producer/core/remote.rb
CHANGED
@@ -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.
|
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
|
@@ -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
|
14
|
-
|
15
|
-
|
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.
|
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:
|
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.
|
254
|
+
rubygems_version: 2.2.2
|
255
255
|
signing_key:
|
256
256
|
specification_version: 4
|
257
257
|
summary: Provisioning tool
|