Class: Chake::Node

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hostname, data = {}) ⇒ Node

Returns a new instance of Node.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/chake/node.rb', line 27

def initialize(hostname, data = {})
  uri = URI.parse(hostname)
  if !uri.host && ((!uri.scheme && uri.path) || (uri.scheme && uri.opaque))
    uri = URI.parse("ssh://#{hostname}")
  end
  if uri.path && uri.path.empty?
    uri.path = nil
  end

  @backend_name = uri.scheme

  @hostname = uri.host
  @port = uri.port
  @username = uri.user || Etc.getpwuid.name
  @remote_username = uri.user
  @path = uri.path || "/var/tmp/chef.#{username}"
  @data = data

  if @hostname.length > self.class.max_node_name_length
    self.class.max_node_name_length = @hostname.length
  end
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



18
19
20
# File 'lib/chake/node.rb', line 18

def data
  @data
end

#hostnameObject (readonly)

Returns the value of attribute hostname.



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

def hostname
  @hostname
end

#pathObject (readonly)

Returns the value of attribute path.



17
18
19
# File 'lib/chake/node.rb', line 17

def path
  @path
end

#portObject (readonly)

Returns the value of attribute port.



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

def port
  @port
end

#remote_usernameObject (readonly)

Returns the value of attribute remote_username.



16
17
18
# File 'lib/chake/node.rb', line 16

def remote_username
  @remote_username
end

#usernameObject (readonly)

Returns the value of attribute username.



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

def username
  @username
end

Class Method Details

.max_node_name_lengthObject



20
21
22
# File 'lib/chake/node.rb', line 20

def self.max_node_name_length
  @max_node_name_length ||= 0
end

.max_node_name_length=(value) ⇒ Object



23
24
25
# File 'lib/chake/node.rb', line 23

def self.max_node_name_length=(value)
  @max_node_name_length = value
end

Instance Method Details

#backendObject



50
51
52
# File 'lib/chake/node.rb', line 50

def backend
  @backend ||= Chake::Backend.get(@backend_name).new(self)
end