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_names(search_options, highlight_value) ⇒ Object
- #found_in_block_names(search_options, highlight_value, formspec: '=%<index>4.d: %<line>s') ⇒ Object
- #read_block_name(line, fenced_start_and_end_regex, block_name_match, block_name_nick_match) ⇒ 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
200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/markdown_exec.rb', line 200 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_names(search_options, highlight_value) ⇒ Object
241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/markdown_exec.rb', line 241 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 |
#found_in_block_names(search_options, highlight_value, formspec: '=%<index>4.d: %<line>s') ⇒ Object
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/markdown_exec.rb', line 212 def found_in_block_names(, highlight_value, formspec: '=%<index>4.d: %<line>s') matched_contents = ( find_file_contents do |line| read_block_name(line, [:fenced_start_and_end_regex], [:block_name_match], [:block_name_nick_match]) end).map.with_index do |(file, contents), index| # [file, contents.map { |detail| format(formspec, detail.index, detail.line) }, index] [file, contents.map do |detail| format(formspec, { index: detail.index, line: detail.line }) end, index] end { section_title: 'block names', 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, matched_contents: matched_contents } end |
#read_block_name(line, fenced_start_and_end_regex, block_name_match, block_name_nick_match) ⇒ Object
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
# File 'lib/markdown_exec.rb', line 255 def read_block_name(line, fenced_start_and_end_regex, block_name_match, block_name_nick_match) return unless line.match(fenced_start_and_end_regex) bm = NamedCaptureExtractor::extract_named_groups(line, block_name_match) return if bm.nil? name = bm[:title] if block_name_nick_match.present? && line =~ Regexp.new(block_name_nick_match) $~[0] else bm && bm[1] ? bm[:title] : name end end |