lib/directory_searcher.rb in markdown_exec-2.0.3.2 vs lib/directory_searcher.rb in markdown_exec-2.0.4

- old
+ new

@@ -108,11 +108,11 @@ @filename_glob = filename_glob end # Searches for the pattern in directory names. # @return [Array<String>] List of matching directory names. - def search_in_directory_names + def find_directory_names match_dirs = [] @paths.each do |path| Find.find(path) do |p| # Find.prune unless @include_subdirectories || path == p match_dirs << p if File.directory?(p) && p.match?(@pattern) @@ -121,11 +121,11 @@ match_dirs end # Searches for the pattern in file names. # @return [Array<String>] List of matching file names. - def search_in_file_names + def find_file_names match_files = [] @paths.each do |path| Find.find(path) do |p| # Find.prune unless @include_subdirectories || path == p next unless File.file?(p) @@ -145,11 +145,11 @@ match_files end # Searches for the pattern in the contents of the files and returns matches along with their file paths and line numbers. # @return [Hash] A hash where each key is a file path and each value is an array of hashes with :line_number and :line keys. - def search_in_file_contents + def find_file_contents match_details = {} @paths.each do |path| Find.find(path) do |p| Find.prune unless @include_subdirectories || path == p @@ -176,11 +176,11 @@ match_details end # # Searches for the pattern in the contents of the files. # # @return [Array<String>] List of matching lines from files. - # def search_in_file_contents + # def find_file_contents # match_lines = [] # @paths.each do |path| # Find.find(path) do |p| # Find.prune unless @include_subdirectories || path == p # next unless File.file?(p) @@ -217,26 +217,26 @@ @pattern = /test_pattern/ @paths = ['./spec'] @searcher = DirectorySearcher.new(@pattern, @paths) end - # Test search_in_directory_names method - def test_search_in_directory_names + # Test find_directory_names method + def test_find_directory_names # Add assertions based on your test directory structure and expected results - assert_equal [], @searcher.search_in_directory_names + assert_equal [], @searcher.find_directory_names end - # Test search_in_file_names method - def test_search_in_file_names + # Test find_file_names method + def test_find_file_names # Add assertions based on your test directory structure and expected results - assert_equal [], @searcher.search_in_file_names + assert_equal [], @searcher.find_file_names end - # Test search_in_file_contents method - def test_search_in_file_contents + # Test find_file_contents method + def test_find_file_contents # Add assertions based on your test directory structure and expected results - assert_equal ({}), @searcher.search_in_file_contents + assert_equal ({}), @searcher.find_file_contents end end # Test class for DirectorySearcher class DirectorySearcherTest2 < Minitest::Test @@ -247,29 +247,29 @@ @filename_glob = nil @searcher_spec = DirectorySearcher.new(@pattern_spec, @paths, filename_glob: @filename_glob) end - # Test search_in_directory_names method for 'spec' - def test_search_in_directory_names_for_spec + # Test find_directory_names method for 'spec' + def test_find_directory_names_for_spec # Replace with actual expected directory names containing 'spec' expected_dirs = ['./spec'] - assert_equal expected_dirs, @searcher_spec.search_in_directory_names + assert_equal expected_dirs, @searcher_spec.find_directory_names end - # Test search_in_file_names method for 'spec' - def test_search_in_file_names_for_spec + # Test find_file_names method for 'spec' + def test_find_file_names_for_spec # Replace with actual expected file names containing 'spec' expected_files = ['./spec/cli_spec.rb', './spec/env_spec.rb', './spec/markdown_exec_spec.rb', './spec/tap_spec.rb'] - assert_equal expected_files, @searcher_spec.search_in_file_names + assert_equal expected_files, @searcher_spec.find_file_names end - # # Test search_in_file_contents method for 'spec' - # def test_search_in_file_contents_for_spec + # # Test find_file_contents method for 'spec' + # def test_find_file_contents_for_spec # # Replace with actual expected lines containing 'spec' # expected_lines = {['Line with spec 1', 'Line with spec 2']} - # assert_equal expected_lines, @searcher_spec.search_in_file_contents + # assert_equal expected_lines, @searcher_spec.find_file_contents # end end end