Class: PartialInspector::Reporter
- Inherits:
-
Object
- Object
- PartialInspector::Reporter
- Includes:
- PartialTree, UnusedPartials, UsedPartials
- Defined in:
- lib/partial_inspector/reporter.rb
Instance Method Summary collapse
- #report_files_rendering_partial(partial_path) ⇒ Object
- #report_partial_tree(partial_path) ⇒ Object
- #report_unused_partials ⇒ Object
Instance Method Details
#report_files_rendering_partial(partial_path) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/partial_inspector/reporter.rb', line 11 def report_files_rendering_partial(partial_path) files = base_scanner(partial_path) return "\e[41m\e[34mINVALID PATH\e[0m\e[0m" if files.empty? search_results_count = files.size grouped_files = combine_unique_files(files) puts "\n\e[36mSEARCH SUMMARY\e[0m" puts "\e[35mTOTAL SEARCH RESULTS\e[0m: \e[32m#{search_results_count}\e[0m" puts "\e[35mTOTAL FILES\e[0m: \e[32m#{grouped_files.keys.size}\e[0m" puts "\n\e[36mDETAILS\e[0m" grouped_files.each do |key, value| puts "\e[35mFILE NAME\e[0m: \e[34m#{key.to_s}\e[0m" file_contents = value file_contents.each do |file_content| puts "\e[35mLINE #{file_content[:line_number]}\e[0m: #{file_content[:line_content]} " end puts "RENDERED \e[32m#{file_contents.size} TIME(S)\e[0m\n\n" end return end |
#report_partial_tree(partial_path) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/partial_inspector/reporter.rb', line 52 def report_partial_tree(partial_path) paths = data_to_build_tree(partial_path) paths.each_with_index do |path, index| puts "\e[35mTREE #{index+1}\e[0m" space = "" path[1..-1].each do |sub_path| puts "#{space}-> #{sub_path}" space = space + "\t" end space="" puts "\n" end return end |
#report_unused_partials ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/partial_inspector/reporter.rb', line 34 def report_unused_partials partials = inspect_unused_partials unused_partials = partials[:unused_partials] puts "\n\e[36mSEARCH SUMMARY\e[0m" puts "\e[35mTOTAL PARTIALS\e[0m: \e[32m#{partials[:total_partials]}\e[0m" puts "\e[35mUSED PARTIALS\e[0m: \e[32m#{partials[:used_partials]}\e[0m" puts "\e[35mUNUSED PARTIALS\e[0m: \e[32m#{unused_partials.size}\e[0m" unless unused_partials.empty? puts "\n\e[36mDETAILS\e[0m" unused_partials.each do |partial| puts partial end end return end |