Sha256: 9dfdfc311c7a56362ba4e67ad58cab4a4442bfb01ec0ad18fb9432d0455c4625
Contents?: true
Size: 792 Bytes
Versions: 12
Compression:
Stored size: 792 Bytes
Contents
module File::Grep def grep(rex, *files) files = files.flatten unless block_given? results = [] grep(rex, files) do |line, file, *args| results << [ line, file ] end return results end files.each do |file| File.readlines(file).each do |line| next unless matches = (rex.match(line)) yield line, file, matches end end end end File.extend File::Grep module File::Grep::Etest def test_grep assert_equal 4, File.grep(/Etest/, __FILE__).length assert_equal 5, File.grep(/ETEST/i, __FILE__).length end def test_greps assert_equal 8, File.grep(/Etest/, [ __FILE__, __FILE__ ]).length assert_equal 8, File.grep(/Etest/, __FILE__, __FILE__ ).length end end if VEX_TEST == "base"
Version data entries
12 entries across 12 versions & 1 rubygems