Class: Chake::Node

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Node.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/chake/node.rb', line 18

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.hostname
  @username = uri.user || Etc.getpwuid.name
  @path = uri.path || "/var/tmp/chef.#{username}"
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



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

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.



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

def path
  @path
end

#usernameObject (readonly)

Returns the value of attribute username.



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

def username
  @username
end

Instance Method Details

#backendObject



35
36
37
# File 'lib/chake/node.rb', line 35

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