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.



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

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

  @backend_name = uri.scheme

  @hostname = uri.host
  @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.



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

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.



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

def path
  @path
end

#remote_usernameObject (readonly)

Returns the value of attribute remote_username.



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

def remote_username
  @remote_username
end

#usernameObject (readonly)

Returns the value of attribute username.



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

def username
  @username
end

Class Method Details

.max_node_name_lengthObject



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

def self.max_node_name_length
  @max_node_name_length ||= 0
end

.max_node_name_length=(value) ⇒ Object



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

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

Instance Method Details

#backendObject



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

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