Class: AutomateIt::AddressManager::Portable
- Inherits:
-
BaseDriver
- Object
- Common
- Plugin::Base
- Plugin::Driver
- BaseDriver
- AutomateIt::AddressManager::Portable
- Defined in:
- lib/automateit/address_manager/portable.rb
Overview
AddressManager::Portable
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.
Constant Summary
Constants inherited from Plugin::Driver
Plugin::Driver::BASE_DRIVER_NAME
Constants included from Constants
Constants::HELPERS_DIR, Constants::INSTALL_DIR, Constants::PERROR, Constants::PEXEC, Constants::PNOTE, Constants::WARNING_BOILERPLATE
Instance Attribute Summary
Attributes inherited from Plugin::Driver
Attributes inherited from Common
Instance Method Summary collapse
-
#addresses ⇒ Object
See AddressManager#addresses.
-
#has?(opts) ⇒ Boolean
See AddressManager#has?.
-
#hostnames ⇒ Object
See AddressManager#hostnames.
-
#suitability(method, *args) ⇒ Object
:nodoc:.
Methods inherited from BaseDriver
Methods inherited from Plugin::Driver
abstract_driver, #available?, base_driver, base_driver?, depends_on, inherited, manager_token, #setup
Methods inherited from Plugin::Base
Methods inherited from Common
#initialize, #log, #nitpick, #noop, #noop=, #noop?, #preview, #preview=, #preview?, #preview_for, #setup, #superuser?, #writing, #writing=, #writing?
Constructor Details
This class inherits a constructor from AutomateIt::Common
Instance Method Details
#addresses ⇒ Object
See AddressManager#addresses
32 33 34 35 36 |
# File 'lib/automateit/address_manager/portable.rb', line 32 def addresses results = Set.new("127.0.0.1") results.merge(TCPSocket.gethostbyname(Socket.gethostname)[3]) rescue SocketError return results.flatten end |
#has?(opts) ⇒ Boolean
See AddressManager#has?
13 14 15 16 17 18 |
# File 'lib/automateit/address_manager/portable.rb', line 13 def has?(opts) raise NotImplementedError.new("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 end |
#hostnames ⇒ Object
See AddressManager#hostnames
21 22 23 24 25 26 27 28 29 |
# File 'lib/automateit/address_manager/portable.rb', line 21 def hostnames results = Set.new results << Socket.gethostname results.merge(Socket.gethostbyname(Socket.gethostname)[1]) rescue SocketError results.each{|name| results.merge(hostnames_for(name))} results << "localhost" return results.to_a.sort end |
#suitability(method, *args) ⇒ Object
:nodoc:
8 9 10 |
# File 'lib/automateit/address_manager/portable.rb', line 8 def suitability(method, *args) # :nodoc: return 1 end |