Class: Node

Inherits:
Object
  • Object
show all
Defined in:
lib/node.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.getObject



10
11
12
# File 'lib/node.rb', line 10

def self.get
  @node
end

.magic(matcher, path) ⇒ Object



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

def self.magic matcher, path
  set resolve(matcher, path)
end

.resolve(matcher, path) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/node.rb', line 22

def self.resolve matcher, path
  Output.banner 'Loading', 'Merging default attributes...'
  @hash = @dna = eval(File.read path)
  Dir[matcher].each do |attr_file|
    next if File.directory? attr_file
    Output.info 'Merging node', attr_file
    @hash = @hash.deep_merge(eval(File.read attr_file) || {}).
      deep_merge(@hash)
  end
  # TODO: remove ARGV
  @hash[:instance_role] = ARGV[1]
  @hash[:platform] = 'ubuntu'
  Hashie::Mash.new(@hash)
end

.set(object) ⇒ Object



6
7
8
# File 'lib/node.rb', line 6

def self.set object
  @node = object
end

Instance Method Details

#dnaObject



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

def dna
  @dna
end