Class: Patch::Hub
- Inherits:
-
Object
- Object
- Patch::Hub
- Defined in:
- lib/patch/hub.rb
Overview
The main application object
Instance Attribute Summary collapse
-
#log ⇒ Object
readonly
Returns the value of attribute log.
-
#patches ⇒ Object
readonly
Returns the value of attribute patches.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Hub
constructor
A new instance of Hub.
-
#ips ⇒ Array<String>
Collected IP addresses for the nodes.
-
#listen(options = {}) ⇒ Hub
Start the hub.
-
#nodes ⇒ Node::Container
All of the nodes used by the patches.
Constructor Details
Instance Attribute Details
#log ⇒ Object (readonly)
Returns the value of attribute log.
6 7 8 |
# File 'lib/patch/hub.rb', line 6 def log @log end |
#patches ⇒ Object (readonly)
Returns the value of attribute patches.
6 7 8 |
# File 'lib/patch/hub.rb', line 6 def patches @patches end |
Instance Method Details
#ips ⇒ Array<String>
Collected IP addresses for the nodes
18 19 20 21 22 |
# File 'lib/patch/hub.rb', line 18 def ips regex = /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/ all_ips = Socket.ip_address_list.map(&:inspect_sockaddr) all_ips.select { |ip| !!ip.match(regex) } end |
#listen(options = {}) ⇒ Hub
Start the hub
28 29 30 31 32 33 34 35 36 |
# File 'lib/patch/hub.rb', line 28 def listen( = {}) begin enable_nodes @thread.join unless !![:background] self rescue SystemExit, Interrupt => exception exit 0 end end |
#nodes ⇒ Node::Container
All of the nodes used by the patches
40 41 42 43 |
# File 'lib/patch/hub.rb', line 40 def nodes nodes = @patches.map { |patch| patch.maps.map(&:nodes) }.flatten.compact.uniq Node::Container.new(nodes) end |