Module: Pod::Downloader
- Defined in:
- lib/cocoapods-imy-bin/native/installer.rb,
lib/cocoapods-imy-bin/native/Downloader.rb
Defined Under Namespace
Classes: Cache
Class Method Summary collapse
-
.download(request, target, can_cache: true, cache_path: Config.instance.cache_root + 'Pods') ⇒ Response
Downloads a pod from the given ‘request` to the given `target` location.
Class Method Details
.download(request, target, can_cache: true, cache_path: Config.instance.cache_root + 'Pods') ⇒ Response
Downloads a pod from the given ‘request` to the given `target` location.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/cocoapods-imy-bin/native/Downloader.rb', line 29 def self.download( request, target, can_cache: true, cache_path: Config.instance.cache_root + 'Pods' ) can_cache &&= !Config.instance.skip_download_cache request = preprocess_request(request) if can_cache raise ArgumentError, 'Must provide a `cache_path` when caching.' unless cache_path cache = Cache.new(cache_path) result = cache.download_pod(request) else raise ArgumentError, 'Must provide a `target` when caching is disabled.' unless target require 'cocoapods/installer/pod_source_preparer' result, = download_request(request, target) Installer::PodSourcePreparer.new(result.spec, result.location).prepare! end if target && result.location && target != result.location UI. "Copying #{request.name} from `#{result.location}` to #{UI.path target}", '> ' do FileUtils.rm_rf target FileUtils.cp_r(result.location, target) file_count = Dir.glob(File.join(target, '**', '*')).select { |file| File.file?(file) }.count if file_count < 2 FileUtils.rm_rf target FileUtils.cp_r(result.location, target) UI.warn "======Copying #{request.name} ==== #{target} 为空,请注意 ======== " end end end result end |