Class: Keela::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/keela/reporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(strategy_name) ⇒ Reporter

Returns a new instance of Reporter.



10
11
12
# File 'lib/keela/reporter.rb', line 10

def initialize(strategy_name)
  @strategy_name = strategy_name
end

Instance Attribute Details

#strategy_nameObject (readonly)

Returns the value of attribute strategy_name.



8
9
10
# File 'lib/keela/reporter.rb', line 8

def strategy_name
  @strategy_name
end

Instance Method Details

#format_yaml(collection) ⇒ Object



39
40
41
# File 'lib/keela/reporter.rb', line 39

def format_yaml(collection)
  indent_yaml_list_items(collection.sort.to_h.to_yaml)
end


28
29
30
31
32
33
34
35
36
37
# File 'lib/keela/reporter.rb', line 28

def print_diff_report(new_unused, removed, excluded_path:, baseline_path:)
  print_new_unused(new_unused, excluded_path) unless new_unused.empty?

  if new_unused.size + removed.size > 0
    puts Rainbow("~" * 80).white.bright
    puts "\n"
  end

  print_removed(removed, baseline_path) unless removed.empty?
end


14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/keela/reporter.rb', line 14

def print_full_report(unused_collection, elapsed_time)
  unused_count = unused_collection.values.flatten.size

  if unused_count > 0
    puts "\nFound #{unused_count} unused #{strategy_name}:\n\n"
    puts format_yaml(unused_collection)
    puts "\n"
  else
    puts Rainbow("No unused #{strategy_name} were found.").green.bright
  end

  puts "Finished in #{elapsed_time.round(2)} seconds."
end