Class: DownloadStrategyDetector Private

Inherits:
Object
  • Object
show all
Defined in:
download_strategy.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Helper class for detecting a download strategy from a URL.

Class Method Summary collapse

Class Method Details

.detect(url, using = nil) ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
# File 'download_strategy.rb', line 1372

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. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
# File 'download_strategy.rb', line 1420

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 :homebrew_curl          then HomebrewCurlDownloadStrategy
  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. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
# File 'download_strategy.rb', line 1385

def self.detect_from_url(url)
  case url
  when GitHubPackages::URL_REGEX
    CurlGitHubPackagesDownloadStrategy
  when %r{^https?://github\.com/[^/]+/[^/]+\.git$}
    GitHubGitDownloadStrategy
  when %r{^https?://.+\.git$},
       %r{^git://},
       %r{^https?://git\.sr\.ht/[^/]+/[^/]+$}
    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{^svn\+http://},
       %r{^http://svn\.apache\.org/repos/},
       %r{^https?://(.+?\.)?sourceforge\.net/svnroot/}
    SubversionDownloadStrategy
  when %r{^cvs://}
    CVSDownloadStrategy
  when %r{^hg://},
       %r{^https?://(.+?\.)?googlecode\.com/hg},
       %r{^https?://(.+?\.)?sourceforge\.net/hgweb/}
    MercurialDownloadStrategy
  when %r{^bzr://}
    BazaarDownloadStrategy
  when %r{^fossil://}
    FossilDownloadStrategy
  else
    CurlDownloadStrategy
  end
end