From aec47d8a19f58a11d397f5421d9408f52353e530 Mon Sep 17 00:00:00 2001 From: Misty De Meo Date: Mon, 2 Jun 2014 21:53:53 -0700 Subject: [PATCH] resource: escape slashes from download_name This is useful to be able to write go resources using their package name as the resource name --- Library/Homebrew/resource.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/resource.rb b/Library/Homebrew/resource.rb index f8cb56e89f..66372ad3e9 100644 --- a/Library/Homebrew/resource.rb +++ b/Library/Homebrew/resource.rb @@ -31,8 +31,15 @@ class Resource @downloader ||= download_strategy.new(download_name, self) end + # Removes /s from resource names; this allows go package names + # to be used as resource names without confusing software that + # interacts with download_name, e.g. github.com/foo/bar + def escaped_name + name.gsub("/", '-') + end + def download_name - name.nil? ? owner.name : "#{owner.name}--#{name}" + name.nil? ? owner.name : "#{owner.name}--#{escaped_name}" end def cached_download