Class: Chake::Node

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/chake/node.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

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_lengthObject



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

#dataObject (readonly)

Returns the value of attribute data.



12
13
14
# File 'lib/chake/node.rb', line 12

def data
  @data
end

#hostnameObject (readonly)

Returns the value of attribute hostname.



12
13
14
# File 'lib/chake/node.rb', line 12

def hostname
  @hostname
end

#portObject (readonly)

Returns the value of attribute port.



12
13
14
# File 'lib/chake/node.rb', line 12

def port
  @port
end

#remote_usernameObject (readonly)

Returns the value of attribute remote_username.



12
13
14
# File 'lib/chake/node.rb', line 12

def remote_username
  @remote_username
end

#silentObject

Returns the value of attribute silent.



14
15
16
# File 'lib/chake/node.rb', line 14

def silent
  @silent
end

#usernameObject (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_managerObject



42
43
44
# File 'lib/chake/node.rb', line 42

def config_manager
  @config_manager ||= Chake::ConfigManager.get(self)
end

#connectionObject



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

#pathObject



48
49
50
# File 'lib/chake/node.rb', line 48

def path
  @path ||= config_manager.path
end