Sha256: 0dfb0e06eaa1d11bbc9e0e1a9a99f810d1a0bf476acb2a438144f74a0767fbc4

Contents?: true

Size: 761 Bytes

Versions: 2

Compression:

Stored size: 761 Bytes

Contents

require 'rainbow'
require 'sshkit'
require 'gaptool_client/api'

module Gaptool
  class InteractionHandler
    attr_reader :host
    def initialize(host)
      @host = host
    end

    def on_data(_command, stream_name, data, _channel)
      case stream_name
      when :stdout
        puts "#{Rainbow("#{@host}").yellow}> #{data}"
      when :stderr
        STDERR.puts "#{Rainbow("#{@host}").red}> #{data}"
      end
    end
  end

  class Host < SSHKit::Host
    attr_reader :info

    def initialize(node)
      super(node['hostname'])
      @info = node
    end

    def method_missing(attr)
      @info[attr]
    end

    def name
      @name ||= Gaptool::API.get_host(@info)
    end

    def handler
      InteractionHandler.new(name)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gaptool-client-0.8.0.pre.alpha6 lib/gaptool_client/host.rb
gaptool-client-0.8.0.pre.alpha5 lib/gaptool_client/host.rb