Class: Chake::Node
Class Attribute Summary collapse
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#remote_username ⇒ Object
readonly
Returns the value of attribute remote_username.
-
#silent ⇒ Object
Returns the value of attribute silent.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #config_manager ⇒ Object
- #connection ⇒ Object
-
#initialize(hostname, data = {}) ⇒ Node
constructor
A new instance of Node.
- #log(msg) ⇒ Object
- #path ⇒ Object
Constructor Details
#initialize(hostname, data = {}) ⇒ Node
Returns a new instance of Node.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/chake/node.rb', line 24 def initialize(hostname, data = {}) uri = parse_uri(hostname) @connection_name = uri.scheme @hostname = uri.host @port = uri.port @username = uri.user || Etc.getpwuid.name @remote_username = uri.user @path = uri.path @data = data set_max_node_length end |
Class Attribute Details
.max_node_name_length ⇒ Object
16 17 18 |
# File 'lib/chake/node.rb', line 16 def self.max_node_name_length @max_node_name_length ||= 0 end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
12 13 14 |
# File 'lib/chake/node.rb', line 12 def data @data end |
#hostname ⇒ Object (readonly)
Returns the value of attribute hostname.
12 13 14 |
# File 'lib/chake/node.rb', line 12 def hostname @hostname end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
12 13 14 |
# File 'lib/chake/node.rb', line 12 def port @port end |
#remote_username ⇒ Object (readonly)
Returns the value of attribute remote_username.
12 13 14 |
# File 'lib/chake/node.rb', line 12 def remote_username @remote_username end |
#silent ⇒ Object
Returns the value of attribute silent.
14 15 16 |
# File 'lib/chake/node.rb', line 14 def silent @silent end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
12 13 14 |
# File 'lib/chake/node.rb', line 12 def username @username end |
Instance Method Details
#config_manager ⇒ Object
42 43 44 |
# File 'lib/chake/node.rb', line 42 def config_manager @config_manager ||= Chake::ConfigManager.get(self) end |
#connection ⇒ Object
36 37 38 |
# File 'lib/chake/node.rb', line 36 def connection @connection ||= Chake::Connection.get(@connection_name).new(self) end |
#log(msg) ⇒ Object
52 53 54 55 56 |
# File 'lib/chake/node.rb', line 52 def log(msg) return if silent puts("%#{Node.max_node_name_length}<host>s: %<msg>s\n" % { host: hostname, msg: msg }) end |
#path ⇒ Object
48 49 50 |
# File 'lib/chake/node.rb', line 48 def path @path ||= config_manager.path end |