Sha256: 10281c756e774f51396c5510dffa416dbf555ee57907908cd350634e918abe50
Contents?: true
Size: 1.62 KB
Versions: 2
Compression:
Stored size: 1.62 KB
Contents
require 'colorize' require 'net/ssh' module AmicoDb class Dump attr_accessor :host attr_accessor :ssh_user attr_accessor :remote_path def initialize(host: AmicoDb.configuration.host, ssh_user: AmicoDb.configuration.ssh_user) self.host = host self.ssh_user = ssh_user end 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 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 def log_before puts '------------------------------------'.colorize(:red) puts "#{ssh_user}@#{host}".colorize(:red) puts '------------------------------------'.colorize(:red) end 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 def log_end puts '--------------------------------------'.colorize(:red) puts 'Hi Rubynetti, close connection.'.colorize(:green) puts '--------------------------------------'.colorize(:red) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
amico-db-0.1.8 | lib/amico-db/dump.rb |
amico-db-0.1.7 | lib/amico-db/dump.rb |