Skip to content

Instantly share code, notes, and snippets.

@v2e4lisp
Created October 10, 2013 13:18
Show Gist options
  • Select an option

  • Save v2e4lisp/6918158 to your computer and use it in GitHub Desktop.

Select an option

Save v2e4lisp/6918158 to your computer and use it in GitHub Desktop.
def files(regex, dir=".")
Dir.chdir(dir) do
ret = Dir[regex].inject([]) {|acc, f| acc << f}
Dir["*/"].inject(ret) {|acc, f| acc << {f => files(regex, f)}}
end
end
puts files("*.py", Dir.home + "/_.py")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment