bashaus bashaus - 6 months ago 9
Ruby Question

Rake get directory name in file glob

If a Rake File exists with the following code:

file 'assets/*/map.a' => ['map.b', 'map.c'] do
# Code goes here...
end


I want to know what the name of the directory in the glob is (instead of the file). Any suggestions?

Answer
file 'assets/*/map.a' => ['map.b', 'map.c'] do |path|
    File.basename(File.dirname(path))
end
Comments