diff --git a/README.md b/README.md index 07a3c05..d0b1b28 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Akainaa (赤いなぁ) +![page view](./img/screenshot.png) + Akainaa is a gem that employs the Coverage library to record the number of executed count of code in a rack application and provides a Web UI that shows the recorded status. @@ -34,9 +36,8 @@ use Akainaa::Middleware run App ``` -Boot up application, access `/akainaa` will return coverage result like this: - -![page view](./img/screenshot.png) +Boot up application, do something, and access `/akainaa`. +It will show Web UI what and how many executed. ## Development diff --git a/img/screenshot.png b/img/screenshot.png index d433f14..52a28bd 100644 Binary files a/img/screenshot.png and b/img/screenshot.png differ diff --git a/lib/akainaa.rb b/lib/akainaa.rb index 135d058..22cc2c4 100644 --- a/lib/akainaa.rb +++ b/lib/akainaa.rb @@ -74,12 +74,22 @@ def call(env) HTML end - private def render_filelist(files, current_path:) + private def render_filelist(coverage_result, current_path:) + files = coverage_result.keys + max_count_on_proj = coverage_result + .values + .map { |cv| cv[:lines].reject(&:nil?).sum } + .max + 1 + max_count_witdh = max_count_on_proj.to_s.size + li_elements = files.sort.map do |file| + total_count_on_file = coverage_result[file][:lines].reject(&:nil?).sum + count_top = (total_count_on_file * 10 / max_count_on_proj).to_i * 10 + class_suffix = file == current_path ? ' current' : '' <<~HTML
  • - #{file} + (#{total_count_on_file.to_s.rjust(max_count_witdh)}) #{file}
  • HTML end.join @@ -87,7 +97,7 @@ def call(env) <<~HTML
    - Akainaa + 赤いなぁ