Class: Hieracles::Formats::Json

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

Overview

format intended to be used for an api server

Instance Method Summary collapse

Methods inherited from Hieracles::Format

#initialize, #show_params

Constructor Details

This class inherits a constructor from Hieracles::Format

Instance Method Details

#allparams(args) ⇒ Object



34
35
36
# File 'lib/hieracles/formats/json.rb', line 34

def allparams(args)
  @node.params(false).merge(alerts).to_json
end

#build_list(hash, notifications, filter) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/hieracles/formats/json.rb', line 38

def build_list(hash, notifications, filter)
  if filter[0]
    { 'notifications' => notifications,
      'payload' => hash.select { |k, e| Regexp.new(filter[0]).match k }
    }.to_json
  else
    { 'notifications' => notifications,
      'payload' => hash
    }.to_json
  end
end

#facts(args) ⇒ Object



13
14
15
16
# File 'lib/hieracles/formats/json.rb', line 13

def facts(args)
  filter(@node.facts, args)
  @node.facts.merge(alerts).to_json
end

#files(_) ⇒ Object



18
19
20
# File 'lib/hieracles/formats/json.rb', line 18

def files(_)
  { 'files' => @node.files }.merge(alerts).to_json
end

#info(args) ⇒ Object



8
9
10
11
# File 'lib/hieracles/formats/json.rb', line 8

def info(args)
  filter(@node.info, args)
  @node.info.merge(alerts).to_json
end

#modules(_) ⇒ Object



26
27
28
# File 'lib/hieracles/formats/json.rb', line 26

def modules(_)
  @node.modules.merge(alerts).to_json
end

#params(args) ⇒ Object



30
31
32
# File 'lib/hieracles/formats/json.rb', line 30

def params(args)
  @node.params(true).merge(alerts).to_json
end

#paths(_) ⇒ Object



22
23
24
# File 'lib/hieracles/formats/json.rb', line 22

def paths(_)
  { 'paths' => @node.paths }.merge(alerts).to_json
end