Class: Shippy::Commander

Inherits:
Object
  • Object
show all
Defined in:
lib/shippy/commander.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_file: nil, verbosity: :info) ⇒ Commander

Returns a new instance of Commander.



7
8
9
10
# File 'lib/shippy/commander.rb', line 7

def initialize(config_file: nil, verbosity: :info)
  @config_file = config_file
  @verbosity = verbosity
end

Instance Attribute Details

#config_file ⇒ Object

Returns the value of attribute config_file.



3
4
5
# File 'lib/shippy/commander.rb', line 3

def config_file
  @config_file
end

#verbosity ⇒ Object

Returns the value of attribute verbosity.



3
4
5
# File 'lib/shippy/commander.rb', line 3

def verbosity
  @verbosity
end

Instance Method Details

#config ⇒ Object



12
13
14
15
16
# File 'lib/shippy/commander.rb', line 12

def config
  @config ||= Shippy::Config
    .new(config_file)
    .tap { |c| configure_sshkit_with(c) }
end

#with_verbosity(level) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/shippy/commander.rb', line 18

def with_verbosity(level)
  old_level = verbosity
  self.verbosity = level
  SSHKit.config.output_verbosity = level
  yield
ensure
  self.verbosity = old_level
  SSHKit.config.output_verbosity = old_level
end