Module: Helper
- Included in:
- Danger::DangerComposeCompilerMetrics
- Defined in:
- lib/compose_compiler_metrics/helper.rb
Instance Method Summary collapse
- #build_markdown_table(headers, rows) ⇒ Object
- #build_variants(dir) ⇒ Object
- #class_report_path(module_name, build_variant) ⇒ Object
- #composable_report_path(module_name, build_variant) ⇒ Object
- #composable_stats_report_path(module_name, build_variant) ⇒ Object
- #folding(summary, details) ⇒ Object
- #installed?(command) ⇒ Boolean
- #metrics_filename(module_name, build_variant) ⇒ Object
Instance Method Details
#build_markdown_table(headers, rows) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/compose_compiler_metrics/helper.rb', line 26 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
4 5 6 7 8 |
# File 'lib/compose_compiler_metrics/helper.rb', line 4 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
22 23 24 |
# File 'lib/compose_compiler_metrics/helper.rb', line 22 def class_report_path(module_name, build_variant) "#{module_name}_#{build_variant}-classes.txt" end |
#composable_report_path(module_name, build_variant) ⇒ Object
18 19 20 |
# File 'lib/compose_compiler_metrics/helper.rb', line 18 def composable_report_path(module_name, build_variant) "#{module_name}_#{build_variant}-composables.txt" end |
#composable_stats_report_path(module_name, build_variant) ⇒ Object
14 15 16 |
# File 'lib/compose_compiler_metrics/helper.rb', line 14 def composable_stats_report_path(module_name, build_variant) "#{module_name}_#{build_variant}-composables.csv" end |
#folding(summary, details) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/compose_compiler_metrics/helper.rb', line 36 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
51 52 53 |
# File 'lib/compose_compiler_metrics/helper.rb', line 51 def installed?(command) system("which #{command} > /dev/null") end |
#metrics_filename(module_name, build_variant) ⇒ Object
10 11 12 |
# File 'lib/compose_compiler_metrics/helper.rb', line 10 def metrics_filename(module_name, build_variant) "#{module_name}_#{build_variant}-module.json" end |