Class: ModelScope::Reports::GithubBase

Inherits:
Base
  • Object
show all
Defined in:
lib/modelscope/reports/github_base.rb

Direct Known Subclasses

Callbacks::Github, Validations::Github

Instance Attribute Summary

Attributes inherited from Base

#callbacks

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from ModelScope::Reports::Base

Instance Method Details

#generateObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/modelscope/reports/github_base.rb', line 6

def generate
  output = ["::group::#{report_title}"]

  @stats.by_model.each_with_index do |(model_name, _), index|
    output << "" if index > 0
    output << "::group::#{model_name}"

    # Add total row first
    total_stats = @stats.stats_for(model_name)
    output << format_group(
      "all",
      total_stats[:total],
      total_stats[:own],
      total_stats[:inherited],
      total_stats[:rails],
      total_stats[:association_generated],
      total_stats[:attribute_generated],
      total_stats[:gems],
      total_stats[:conditional]
    )

    # Group and sort callbacks
    grouped_callbacks = @stats.by_model[model_name].group_by { |cb| format_group_name(cb) }

    grouped_callbacks.keys.sort.each do |group_name|
      group_callbacks = grouped_callbacks[group_name]
      output << format_group(
        group_name,
        group_callbacks.size,
        group_callbacks.count { |cb| cb.origin == :own },
        group_callbacks.count(&:inherited),
        group_callbacks.count { |cb| cb.origin == :rails },
        group_callbacks.count(&:association_generated),
        group_callbacks.count(&:attribute_generated),
        group_callbacks.count { |cb| cb.origin == :gems },
        group_callbacks.count(&:conditional)
      )
    end

    output << "::endgroup::"
  end

  output << "::endgroup::"
  output.join("\n")
end