https://github.com/Homebrew/homebrew/blob/master/Library/Homebrew/resource.rb#L11

You should be able to use `r.name` instead of messing around with the downloaded names.