Module: Leap::Trace

Defined in:
lib/sniff/leap_ext.rb

Instance Method Summary collapse

Instance Method Details

#traceObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/sniff/leap_ext.rb', line 3

def trace
  @deliberations.inject({}) do |delibs, (goal, deliberation)|
    delibs[goal] = deliberation.reports.inject([]) do |reports, report|
      item = {
        :committee => report.committee.name,
        :quorum => report.quorum.name,
        :result => deliberation[report.committee.name].to_s,
      }

      item[:params] = report.quorum.characteristics.inject({}) do |hsh, name|
        hsh[name] = deliberation[name].to_s
        hsh
      end

      item[:compliance] = report.quorum.compliance

      reports << item
    end
    delibs
  end
end

#trace_reportObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/sniff/leap_ext.rb', line 25

def trace_report
  trace.each do |goal, steps|
    puts goal
    if steps
      steps.each do |step|
        puts "  #{step[:committee]} #{step[:quorum]}"
        unless step[:params].empty?
          puts "    Params: "
          step[:params].inspect.split("\n").each { |p| puts "      #{p}" }
        end
        puts "    Complies: "
        puts "      #{step[:compliance]}"
        puts "    Result: #{step[:result].inspect}\n"
      end
    else
      puts "  Not computed"
    end
  end
end