Sha256: 83b5f86bc0627eecefecec1f7381d6890f7cb63c9274cfdfdb4bf06e0c30b1ae

Contents?: true

Size: 724 Bytes

Versions: 11

Compression:

Stored size: 724 Bytes

Contents

require 'net/telnet'

module Auger
  class Project
    def telnet(port = 23, &block)
      @connections << Telnet.load(port, &block)
    end
  end

  class Telnet < Auger::Connection
    def timeout(value)
      @options[:timeout] = value.to_i
    end

    def open(host, options)
      ## telnet opts array needs capitalized strings as keys
      opts = { 'Host' => host }
      options.each { |key, value| opts[key.to_s.capitalize] = value }
      Net::Telnet::new(opts)
    end

    def close(telnet)
      telnet.close
    end

    def cmd(arg, &block)
      @requests << TelnetRequest.load(arg, &block)
    end
  end

  class TelnetRequest < Auger::Request
    def run(telnet)
      telnet.cmd(@arg)
    end
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
auger-1.3.6 lib/auger/plugin/telnet.rb
auger-1.3.5 lib/auger/plugin/telnet.rb
auger-1.3.4 lib/auger/plugin/telnet.rb
auger-1.3.3 lib/plugins/telnet.rb
auger-1.3.2 lib/plugins/telnet.rb
auger-1.3.1 lib/plugins/telnet.rb
auger-1.3.0 lib/plugins/telnet.rb
auger-1.2.4 lib/plugins/telnet.rb
auger-1.2.3 lib/plugins/telnet.rb
auger-1.2.2 lib/plugins/telnet.rb
auger-1.2.0 lib/plugins/telnet.rb