minionizer 0.2.1 → 0.3.0

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: ab6c86800be7b1dcd9e3c4161b794321b16386b4
4
- data.tar.gz: e96fdac6cac8c7b70eefa8f431291ce478b2e9a8
3
+ metadata.gz: 7690fcfb80c2f59841e1de580c8307eb1dcdbe13
4
+ data.tar.gz: 17c4557d0afebc778ff1dd75e188e208361b49bb
5
5
  SHA512:
6
- metadata.gz: 2f26142169c727649b3b1780753cf4df4d3ff30d02061d3430c72d6fb9267c324b534091258c9de310d73b7565acd9e274d34488ff9074b3cba5b2eab20b5c23
7
- data.tar.gz: ea619f4f6272c7c8652e170a06f0fac2b375cea1e43a10c8fc04c48250cfae673886661fa54740d4c4d81d4b5121aea7898b0075909cf13cc1f0ddd7eb684651
6
+ metadata.gz: 5286634c47d7b60f216ffce792c4955dd71a783cefbce1b3a3b8dc925630b3e88e58c99c1a65349dbb56fe5bf21f529f59d4d76d56269865958cff8e0fffa547
7
+ data.tar.gz: 6956bed9167c3a2d3806188c3c3ffeb1b1a7588411e541590822b1ba04d4278b915137a92c21dcd51b15b0bab6af5ea6fb231683e246a66b3db16ca231deb9e4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- minionizer (0.2.0)
4
+ minionizer (0.2.1)
5
5
  activesupport (~> 4.1)
6
6
  binding_of_caller (~> 0.7)
7
7
  net-scp (~> 1.2)
@@ -10,14 +10,14 @@ PATH
10
10
  GEM
11
11
  remote: http://rubygems.org/
12
12
  specs:
13
- activesupport (4.2.6)
13
+ activesupport (4.2.8)
14
14
  i18n (~> 0.7)
15
- json (~> 1.7, >= 1.7.7)
16
15
  minitest (~> 5.1)
17
16
  thread_safe (~> 0.3, >= 0.3.4)
18
17
  tzinfo (~> 1.1)
19
18
  binding_of_caller (0.7.2)
20
19
  debug_inspector (>= 0.0.1)
20
+ concurrent-ruby (1.0.5)
21
21
  coveralls (0.7.1)
22
22
  multi_json (~> 1.3)
23
23
  rest-client
@@ -27,17 +27,17 @@ GEM
27
27
  debug_inspector (0.0.2)
28
28
  docile (1.1.5)
29
29
  fakefs (0.6.0)
30
- i18n (0.7.0)
31
- json (1.8.3)
30
+ i18n (0.9.5)
31
+ concurrent-ruby (~> 1.0)
32
32
  metaclass (0.0.4)
33
33
  mime-types (2.4.3)
34
- minitest (5.9.0)
34
+ minitest (5.11.3)
35
35
  mocha (1.1.0)
36
36
  metaclass (~> 0.0.1)
37
37
  multi_json (1.10.1)
38
38
  net-scp (1.2.1)
39
39
  net-ssh (>= 2.6.5)
40
- net-ssh (2.9.1)
40
+ net-ssh (2.9.4)
41
41
  netrc (0.8.0)
42
42
  rake (10.3.2)
43
43
  rest-client (1.7.2)
@@ -51,9 +51,9 @@ GEM
51
51
  term-ansicolor (1.3.0)
52
52
  tins (~> 1.0)
53
53
  thor (0.19.1)
54
- thread_safe (0.3.5)
54
+ thread_safe (0.3.6)
55
55
  tins (1.3.3)
56
- tzinfo (1.2.2)
56
+ tzinfo (1.2.5)
57
57
  thread_safe (~> 0.1)
58
58
 
59
59
  PLATFORMS
@@ -63,9 +63,9 @@ DEPENDENCIES
63
63
  coveralls
64
64
  fakefs (~> 0.5)
65
65
  minionizer!
66
- minitest (~> 5.4)
66
+ minitest (~> 5.11)
67
67
  mocha (~> 1.0)
68
68
  rake (~> 10.3)
69
69
 
70
70
  BUNDLED WITH
71
- 1.12.2
71
+ 1.13.5
data/lib/minionizer.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'active_support/core_ext/hash/indifferent_access'
2
+ require 'active_support/core_ext/module/delegation'
2
3
  require 'active_support/inflector'
3
4
  require 'binding_of_caller'
4
5
  require 'erb'
@@ -4,31 +4,16 @@ module Minionizer
4
4
 
5
5
  def initialize(fqdn, config, session_constructor = Session)
6
6
  @fqdn = fqdn
7
- @config = config
7
+ @config = config.minions[fqdn]
8
8
  @session_constructor = session_constructor
9
9
  end
10
10
 
11
11
  def session
12
- @session ||= session_constructor.new(fqdn, ssh_credentials)
12
+ @session ||= session_constructor.new(self)
13
13
  end
14
14
 
15
15
  def roles
16
- my_config['roles']
17
- end
18
-
19
- #######
20
- private
21
- #######
22
-
23
- def ssh_credentials
24
- {
25
- 'username' => my_config['ssh']['username'],
26
- 'password' => my_config['ssh']['password']
27
- }
28
- end
29
-
30
- def my_config
31
- config.minions[fqdn]
16
+ config['roles']
32
17
  end
33
18
  end
34
19
  end
@@ -1,12 +1,15 @@
1
1
  require 'securerandom'
2
2
  module Minionizer
3
3
  class Session
4
- attr_reader :fqdn, :username, :password, :ssh_connector, :scp_connector, :command_executor
4
+ attr_reader :minion, :ssh_connector, :scp_connector, :command_executor
5
5
 
6
- def initialize(fqdn, credentials, ssh_connector=Net::SSH, scp_connector=Net::SCP, command_executor=CommandExecution)
7
- @fqdn = fqdn
8
- @username = credentials['username']
9
- @password = credentials['password']
6
+ delegate :fqdn, :config, to: :minion
7
+
8
+ def initialize(minion,
9
+ ssh_connector=Net::SSH,
10
+ scp_connector=Net::SCP,
11
+ command_executor=CommandExecution)
12
+ @minion = minion
10
13
  @ssh_connector = ssh_connector
11
14
  @scp_connector = scp_connector
12
15
  @command_executor = command_executor
@@ -60,12 +63,15 @@ module Minionizer
60
63
  end
61
64
 
62
65
  def ssh_connection
63
- @ssh_connection ||= ssh_connector.start(fqdn, username, password: password)
66
+ @ssh_connection ||= ssh_connector.start(*connection_args)
64
67
  end
65
68
 
66
69
  def scp_connection
67
- @scp_connection ||= scp_connector.start(fqdn, username, password: password)
70
+ @scp_connection ||= scp_connector.start(*connection_args)
68
71
  end
69
72
 
73
+ def connection_args
74
+ [fqdn, config['ssh']['username'], password: config['ssh']['password']]
75
+ end
70
76
  end
71
77
  end
@@ -1,3 +1,3 @@
1
1
  module Minionizer
2
- VERSION = '0.2.1'
2
+ VERSION = '0.3.0'
3
3
  end
data/minionizer.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
 
18
18
  s.add_development_dependency('fakefs', '~> 0.5')
19
19
  s.add_development_dependency('mocha', '~> 1.0')
20
- s.add_development_dependency('minitest', '~> 5.4')
20
+ s.add_development_dependency('minitest', '~> 5.11')
21
21
  s.add_development_dependency('rake', '~> 10.3')
22
22
 
23
23
  s.files = `git ls-files`.split("\n")
data/test/test_helper.rb CHANGED
@@ -190,4 +190,3 @@ module FakeFS
190
190
  end
191
191
  end
192
192
  end
193
-
@@ -25,7 +25,7 @@ module Minionizer
25
25
  let(:session) { quacks_like_instance_of(Session) }
26
26
 
27
27
  it 'creates a session' do
28
- session_constructor.expects(:new).with(fqdn, credentials).returns(session)
28
+ session_constructor.expects(:new).with(minion).returns(session)
29
29
  minion.session
30
30
  end
31
31
  end
@@ -40,5 +40,3 @@ module Minionizer
40
40
  end
41
41
  end
42
42
  end
43
-
44
-
@@ -7,16 +7,25 @@ module Minionizer
7
7
  let(:fqdn) { 'foo.bar.com' }
8
8
  let(:username) { 'foo' }
9
9
  let(:password) { 'bar' }
10
- let(:credentials) {{ 'username' => username, 'password' => password }}
10
+ let(:config) do
11
+ { 'ssh' => { 'username' => username,
12
+ 'password' => password }}
13
+ end
14
+ let(:minion) { mock('minion') }
11
15
  let(:ssh_connector) { mock('ssh_connector') }
12
16
  let(:scp_connector) { mock('scp_connector') }
13
17
  let(:command_executor) { mock('CommandExecution') }
14
18
  let(:execution) { mock('execution') }
15
19
  let(:ssh_connection) { mock('ssh_connection') }
16
20
  let(:scp_connection) { mock('scp_connection') }
17
- let(:session) { Session.new(fqdn, credentials, ssh_connector, scp_connector, command_executor) }
21
+ let(:session) { Session.new(minion, ssh_connector, scp_connector, command_executor) }
18
22
  let(:start_args) { [fqdn, username, { password: password }]}
19
23
 
24
+ before do
25
+ minion.stubs(:config).returns(config)
26
+ minion.stubs(:fqdn).returns(fqdn)
27
+ end
28
+
20
29
  it 'instantiates' do
21
30
  assert_kind_of(Session, session)
22
31
  end
@@ -65,7 +74,9 @@ module Minionizer
65
74
  let(:command) { 'foobar' }
66
75
 
67
76
  before do
68
- ssh_connector.expects(:start).with(*start_args).returns(ssh_connection)
77
+ ssh_connector.expects(:start)
78
+ .with(*start_args)
79
+ .returns(ssh_connection)
69
80
  end
70
81
 
71
82
  describe '#sudo' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minionizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan S. Garvin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-09 00:00:00.000000000 Z
11
+ date: 2018-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '5.4'
103
+ version: '5.11'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '5.4'
110
+ version: '5.11'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rake
113
113
  requirement: !ruby/object:Gem::Requirement