Module: Helper

Included in:
Danger::DangerComposeCompilerMetrics
Defined in:
lib/compose_compiler_metrics/helper.rb

Instance Method Summary collapse

Instance Method Details

#build_markdown_table(headers, rows) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/compose_compiler_metrics/helper.rb', line 24

def build_markdown_table(headers, rows)
  [].tap do |table|
    table << "| #{headers.join(' | ')} |"
    table << "| #{headers.map { |h| '---' }.join(' | ')} |"
    rows.each do |row|
      table << "| #{row.join(' | ')} |"
    end
  end.join("\n")
end

#build_variants(dir) ⇒ Object



2
3
4
5
6
# File 'lib/compose_compiler_metrics/helper.rb', line 2

def build_variants(dir)
  Dir.glob("#{dir}/*").
    map { |s| File.basename(s).split(/[_\-]/).take(2) }.
    uniq
end

#class_report_path(module_name, build_variant) ⇒ Object



20
21
22
# File 'lib/compose_compiler_metrics/helper.rb', line 20

def class_report_path(module_name, build_variant)
  "#{module_name}_#{build_variant}-classes.txt"
end

#composable_report_path(module_name, build_variant) ⇒ Object



16
17
18
# File 'lib/compose_compiler_metrics/helper.rb', line 16

def composable_report_path(module_name, build_variant)
  "#{module_name}_#{build_variant}-composables.txt"
end

#composable_stats_report_path(module_name, build_variant) ⇒ Object



12
13
14
# File 'lib/compose_compiler_metrics/helper.rb', line 12

def composable_stats_report_path(module_name, build_variant)
  "#{module_name}_#{build_variant}-composables.csv"
end

#folding(summary, details) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/compose_compiler_metrics/helper.rb', line 34

def folding(summary, details)
  "  <details>\n  <summary>\n\n  \#{summary}\n\n  </summary>\n\n  \#{details}\n\n  </details>\n  HTML\nend\n"

#installed?(command) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/compose_compiler_metrics/helper.rb', line 49

def installed?(command)
  system("which #{command} > /dev/null")
end

#metrics_filename(module_name, build_variant) ⇒ Object



8
9
10
# File 'lib/compose_compiler_metrics/helper.rb', line 8

def metrics_filename(module_name, build_variant)
  "#{module_name}_#{build_variant}-module.json"
end