Skip to content

Commit

Permalink
Add hide_not_executed_files option to Akainaa.start method
Browse files Browse the repository at this point in the history
  • Loading branch information
riseshia committed Sep 2, 2024
1 parent 8d237ed commit ac63ffd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Bug fix: nested method call won't handled
- Bug fix: Empty 302 response body on /akainaa/reset
- Feature: Add `ignore_glob_patterns` option to `Akainaa.start` method
- Feature: Add `hide_not_executed_files` option to `Akainaa.start` method

## [0.1.2] - 2024-05-06

Expand Down
11 changes: 9 additions & 2 deletions lib/akainaa.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ module Akainaa
class Error < StandardError; end

class << self
attr_accessor :project_dir, :ignore_files
attr_accessor :project_dir, :ignore_files, :hide_not_executed_files

def start(project_dir:, ignore_glob_patterns: [])
def start(
project_dir:,
ignore_glob_patterns: [],
hide_not_executed_files: false,
)
@project_dir = project_dir
@project_dir += '/' unless @project_dir.end_with?('/')
ignore_files = ignore_glob_patterns.flat_map do |pattern|
Dir["#{@project_dir}#{pattern}"].to_a
end
@ignore_files = Set.new(ignore_files)
@hide_not_executed_files = hide_not_executed_files

Coverage.start(lines: true)
end
Expand Down Expand Up @@ -88,6 +93,8 @@ def call(env)

li_elements = files.sort.map do |file|
total_count_on_file = coverage_result[file][:lines].reject(&:nil?).sum
next '' if Akainaa.hide_not_executed_files && total_count_on_file == 0

count_top = (total_count_on_file * 10 / max_count_on_proj).to_i * 10

class_suffix = file == current_path ? ' current' : ''
Expand Down

0 comments on commit ac63ffd

Please sign in to comment.