Skip to content

Instantly share code, notes, and snippets.

@akitsukada
Created October 15, 2011 11:17
Show Gist options
  • Save akitsukada/1289428 to your computer and use it in GitHub Desktop.
Save akitsukada/1289428 to your computer and use it in GitHub Desktop.
つかだのめも_phpファイル内のarrayパース
#!/usr/bin/env ruby
# -*- coding:UTF-8 -*-
def parse(suite)
realpath = File::expand_path suite
if !File.exists?(realpath)
puts '与えられたsuiteファイルは存在しません'
puts '=>[' + realpath + ']'
exit
end
fp = open(realpath)
is_in_array = false
testfiles = []
fp.each do |line|
next if /^ *\/\// =~ line || /^ *\/\*/ =~ line
is_in_array = true if /array *\(/ =~ line
if is_in_array
/['"](.*php)['"]/ =~ line
match = $~
testfiles << match[1] if match
end
end
testfiles
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment