Class: Hieracles::Formats::Csv

Inherits:
Hieracles::Format show all
Defined in:
lib/hieracles/formats/csv.rb

Overview

for db compatibility

Constant Summary collapse

CVS_DELIM =
';'

Instance Method Summary collapse

Methods inherited from Hieracles::Format

#allparams, #initialize, #modules, #params, #show_params

Constructor Details

This class inherits a constructor from Hieracles::Format

Instance Method Details

#build_head(without_common) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/hieracles/formats/csv.rb', line 23

def build_head(without_common)
  output = []
  @node.files(without_common).each do |f|
    output << f
  end
  output += %w(var value overriden)
  make_csv output
end

#build_modules_line(key, value) ⇒ Object



50
51
52
# File 'lib/hieracles/formats/csv.rb', line 50

def build_modules_line(key, value)
  make_csv [key, value]
end

#build_params_line(key, value, filter) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/hieracles/formats/csv.rb', line 32

def build_params_line(key, value, filter)
  output = ''
  if !filter || Regexp.new(filter).match(key)
    first = value.pop
    if is_merged? first
      output << build_line('-', key, first[:merged])
      output << build_line(first[:file], key, first[:value], '1')
    else
      output << build_line(first[:file], key, first[:value])
    end
    while value.count > 0
      overriden = value.pop
      output << build_line(overriden[:file], key, overriden[:value], '1')
    end
  end
  output
end

#facts(_) ⇒ Object



11
12
13
# File 'lib/hieracles/formats/csv.rb', line 11

def facts(_)
  make_csv(@node.facts.keys) + make_csv(@node.facts.values)
end

#files(_) ⇒ Object



15
16
17
# File 'lib/hieracles/formats/csv.rb', line 15

def files(_)
  make_csv @node.files
end

#info(_) ⇒ Object



7
8
9
# File 'lib/hieracles/formats/csv.rb', line 7

def info(_)
  make_csv @node.info.values
end

#paths(_) ⇒ Object



19
20
21
# File 'lib/hieracles/formats/csv.rb', line 19

def paths(_)
  make_csv @node.paths
end