Class: MarkdownExec::SearchResultsReport
- Inherits:
-
DirectorySearcher
- Object
- DirectorySearcher
- MarkdownExec::SearchResultsReport
- Defined in:
- lib/markdown_exec.rb
Instance Attribute Summary
Attributes inherited from DirectorySearcher
#filename_glob, #include_subdirectories, #paths, #pattern
Instance Method Summary collapse
- #directory_names(search_options, highlight_value) ⇒ Object
- #file_contents(search_options, highlight_value) ⇒ Object
- #file_names(search_options, highlight_value) ⇒ Object
Methods inherited from DirectorySearcher
#find_directory_names, #find_file_contents, #find_file_names, #initialize
Constructor Details
This class inherits a constructor from DirectorySearcher
Instance Method Details
#directory_names(search_options, highlight_value) ⇒ Object
107 108 109 110 111 112 113 114 |
# File 'lib/markdown_exec.rb', line 107 def directory_names(, highlight_value) matched_directories = find_directory_names { section_title: 'directory names', data: matched_directories, formatted_text: [{ content: AnsiFormatter.new().format_and_highlight_array(matched_directories, highlight: [highlight_value]) }] } end |
#file_contents(search_options, highlight_value) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/markdown_exec.rb', line 116 def file_contents(, highlight_value) matched_contents = find_file_contents.map.with_index do |(file, contents), index| [file, contents.map { |detail| format('=%4.d: %s', detail.index, detail.line) }, index] end { section_title: 'file contents', data: matched_contents.map(&:first), formatted_text: matched_contents.map do |(file, details, index)| { header: format('- %3.d: %s', index + 1, file), content: AnsiFormatter.new().format_and_highlight_array( details, highlight: [highlight_value] ) } end } end |
#file_names(search_options, highlight_value) ⇒ Object
133 134 135 136 137 138 139 140 141 142 |
# File 'lib/markdown_exec.rb', line 133 def file_names(, highlight_value) matched_files = find_file_names { section_title: 'file names', data: matched_files, formatted_text: [{ content: AnsiFormatter.new().format_and_highlight_array( matched_files, highlight: [highlight_value] ).join("\n") }] } end |