Skip to content

Instantly share code, notes, and snippets.

@igaiga
Created April 30, 2014 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igaiga/11423927 to your computer and use it in GitHub Desktop.
Save igaiga/11423927 to your computer and use it in GitHub Desktop.
grep_test_line.rb
# ruby のテストからdef test_XXX のXXXを抽出
require "ap"
File.open("test_enum.rb") do |file|
include_def_lines = file.readlines.grep(/def/)
def_names = []
include_def_lines.each do |line|
line =~ /def test_+(.*)$/
match = $1
def_names << match if match
end
ap def_names
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment