Method: Inspec::Profile#info

Defined in:
lib/inspec/profile.rb

#infoObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/inspec/profile.rb', line 53

def info
  res = @params.dup
  rules = {}
  res[:rules].each do |gid, group|
    next if gid.to_s.empty?
    path = gid.sub(File.join(@path, ''), '')
    rules[path] = { title: path, rules: {} }
    group.each do |id, rule|
      next if id.to_s.empty?
      data = rule.dup
      data.delete(:checks)
      data[:impact] ||= 0.5
      data[:impact] = 1.0 if data[:impact] > 1.0
      data[:impact] = 0.0 if data[:impact] < 0.0
      rules[path][:rules][id] = data
      # TODO: temporarily flatten the group down; replace this with
      # proper hierarchy later on
      rules[path][:title] = data[:group_title]
    end
  end
  res[:rules] = rules
  res
end