Class AutomateIt::AddressManager::Portable
In: lib/automateit/address_manager/portable.rb
Parent: AutomateIt::AddressManager::BaseDriver


A pure-Ruby, portable driver for the AddressManager which provides minimal support for querying the hostname using sockets. Although it lacks advanced features found in other drivers, it will work on all platforms.


addresses   has?   hostnames  

Public Instance methods

See AddressManager#addresses


# File lib/automateit/address_manager/portable.rb, line 31
  def addresses
    results ="")
    results.merge(TCPSocket.gethostbyname(Socket.gethostname)[3]) rescue SocketError
    return results.flatten

See AddressManager#has?


# File lib/automateit/address_manager/portable.rb, line 13
  def has?(opts)
    raise"this driver doesn't support queries for devices or labels") if opts[:device] or opts[:label]
    result = true
    result &= addresses.include?(opts[:address]) if opts[:address]
    return result

See AddressManager#hostnames


# File lib/automateit/address_manager/portable.rb, line 21
  def hostnames
    results = []
    results << Socket.gethostname
    results << "localhost"
    results += Socket.gethostbyname(Socket.gethostname)[1] rescue SocketError
    results +={|name| hostnames_for(name)}.flatten
    return results.sort.uniq