175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
# File 'lib/lace/download_strategy.rb', line 175
def self.detect_from_uri(uri)
is_git_dir = File.directory?("#{uri}/.git")
has_single_slash = uri.scan('/').count == 1
via_ssh = uri.start_with?('git@')
if File.directory?(uri) && !is_git_dir && !via_ssh
return LocalFileStrategy
elsif is_git_dir
return GitDownloadStrategy
elsif has_single_slash && !via_ssh
return GitHubDownloadStrategy
end
case uri
when /^git@/ then GitDownloadStrategy
when %r{^https?://.+\.git$} then GitDownloadStrategy
else
raise "Cannot determine download startegy from #{uri}"
end
end
|