class AmicoDb::Dump
Attributes
host[RW]
remote_path[RW]
ssh_user[RW]
Public Class Methods
new(host: AmicoDb.configuration.host, ssh_user: AmicoDb.configuration.ssh_user)
click to toggle source
# File lib/amico-db/dump.rb, line 9 def initialize(host: AmicoDb.configuration.host, ssh_user: AmicoDb.configuration.ssh_user) self.host = host self.ssh_user = ssh_user end
Public Instance Methods
call()
click to toggle source
# File lib/amico-db/dump.rb, line 15 def call log_before Net::SSH.start(host, ssh_user) do |ssh| log_start ssh.open_channel do |channel| execute_stuff(channel) end ssh.loop end end
Private Instance Methods
execute_stuff(channel)
click to toggle source
# File lib/amico-db/dump.rb, line 28 def execute_stuff(channel) channel.request_pty commands = DumpCmd.new.call channel.exec(commands) do |ch| puts commands.colorize(:cyan) ch.on_data do |_c, data| puts "Il server dice: #{data.inspect}".colorize(:blue) end end channel.on_close { log_end } end
log_before()
click to toggle source
# File lib/amico-db/dump.rb, line 40 def log_before puts '------------------------------------'.colorize(:red) puts "#{ssh_user}@#{host}".colorize(:red) puts '------------------------------------'.colorize(:red) end
log_end()
click to toggle source
# File lib/amico-db/dump.rb, line 54 def log_end puts '--------------------------------------'.colorize(:red) puts 'Hi Rubynetti, close connection.'.colorize(:green) puts '--------------------------------------'.colorize(:red) end
log_start()
click to toggle source
# File lib/amico-db/dump.rb, line 46 def log_start puts '------------------------------------'.colorize(:red) puts '--- RUBYNETTI DUMP POWER -----------'.colorize(:red) puts '------------------------------------'.colorize(:red) puts 'Connected to server'.colorize(:blue) puts '------------------------------------'.colorize(:red) end