Class: DownloadStrategyDetector Private
- Inherits:
-
Object
- Object
- DownloadStrategyDetector
- Defined in:
- Library/Homebrew/download_strategy.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Helper class for detecting a download strategy from a URL.
Class Method Summary collapse
- .detect(url, using = nil) ⇒ Object private
- .detect_from_symbol(symbol) ⇒ Object private
- .detect_from_url(url) ⇒ Object private
Class Method Details
.detect(url, using = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 |
# File 'Library/Homebrew/download_strategy.rb', line 1178 def self.detect(url, using = nil) if using.nil? detect_from_url(url) elsif using.is_a?(Class) && using < AbstractDownloadStrategy using elsif using.is_a?(Symbol) detect_from_symbol(using) else raise TypeError, "Unknown download strategy specification #{using.inspect}" end end |
.detect_from_symbol(symbol) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 |
# File 'Library/Homebrew/download_strategy.rb', line 1225 def self.detect_from_symbol(symbol) case symbol when :hg then MercurialDownloadStrategy when :nounzip then NoUnzipCurlDownloadStrategy when :git then GitDownloadStrategy when :bzr then BazaarDownloadStrategy when :svn then SubversionDownloadStrategy when :curl then CurlDownloadStrategy when :cvs then CVSDownloadStrategy when :post then CurlPostDownloadStrategy when :fossil then FossilDownloadStrategy else raise TypeError, "Unknown download strategy #{symbol} was requested." end end |
.detect_from_url(url) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 |
# File 'Library/Homebrew/download_strategy.rb', line 1191 def self.detect_from_url(url) case url when %r{^https?://github\.com/[^/]+/[^/]+\.git$} GitHubGitDownloadStrategy when %r{^https?://.+\.git$}, %r{^git://} GitDownloadStrategy when %r{^https?://www\.apache\.org/dyn/closer\.cgi}, %r{^https?://www\.apache\.org/dyn/closer\.lua} CurlApacheMirrorDownloadStrategy when %r{^https?://(.+?\.)?googlecode\.com/svn}, %r{^https?://svn\.}, %r{^svn://}, %r{^https?://(.+?\.)?sourceforge\.net/svnroot/} SubversionDownloadStrategy when %r{^cvs://} CVSDownloadStrategy when %r{^hg://}, %r{^https?://(.+?\.)?googlecode\.com/hg} MercurialDownloadStrategy when %r{^bzr://} BazaarDownloadStrategy when %r{^fossil://} FossilDownloadStrategy when %r{^svn\+http://}, %r{^http://svn\.apache\.org/repos/} SubversionDownloadStrategy when %r{^https?://(.+?\.)?sourceforge\.net/hgweb/} MercurialDownloadStrategy else CurlDownloadStrategy end end |