class DownloadStrategyDetector

Public Class Methods

detect(uri) click to toggle source
# File lib/lace/download_strategy.rb, line 180
def self.detect(uri)
    detect_from_uri(uri)
end
detect_from_uri(uri) click to toggle source
# File lib/lace/download_strategy.rb, line 184
def self.detect_from_uri(uri)
  is_git_dir = File.directory?(uri+"/.git")
  has_single_slash = uri.scan("/").count == 1
  if File.directory?(uri) && !is_git_dir
    return LocalFileStrategy
  elsif is_git_dir
    return GitDownloadStrategy
  elsif has_single_slash
    return AbbrevGitDownloadStrategy
  end

  case uri
  when %r[^git://] then GitDownloadStrategy
  when %r[^https?://.+\.git$] then GitDownloadStrategy
    # else CurlDownloadStrategy
  else
    raise "Cannot determine download startegy from #{uri}"
  end
end