Class: LgPodPlugin::LDownloader

Inherits:
Object
  • Object
show all
Defined in:
lib/lg_pod_plugin/downloader.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ LDownloader

Returns a new instance of LDownloader.



12
13
14
15
16
17
18
19
# File 'lib/lg_pod_plugin/downloader.rb', line 12

def initialize(name, options = {})
  self.name = name
  self.options = Hash.new.deep_merge(options)
  self.git = self.options[:git]
  self.tag = self.options[:tag]
  self.branch = self.options[:branch]
  self.commit = self.options[:commit]
end

Instance Method Details

#pre_download_podObject

预下载处理



22
23
24
25
26
27
28
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
# File 'lib/lg_pod_plugin/downloader.rb', line 22

def pre_download_pod
  if self.branch
    LgPodPlugin.log_green "Using `#{name}` (#{branch})"
  else
    LgPodPlugin.log_green "Using `#{name}`"
  end
  hash_map = LRequest.shared.get_cache_key_params
  # 发现本地有缓存, 不需要更新缓存
  if LRequest.shared.single_git
    need_download = LRequest.shared.cache.find_pod_cache(name, hash_map)
    unless need_download
      hash_map.delete(:commit)
      need_download = LRequest.shared.cache.find_pod_cache(name, hash_map)
    end
  else
    need_download = LRequest.shared.cache.find_pod_cache(name, hash_map)
  end
  if need_download
    LgPodPlugin.log_green "find the new commit of `#{name}`, Git downloading now."
    # 本地 git 下载 pod 目录
    LRequest.shared.git_util.pre_download_git_repository
  else
    is_delete = LRequest.shared.request_params["is_delete"] ||= false
    if self.real_name == self.name
      LRequest.shared.libs.delete(self.name) if is_delete
    else
      LRequest.shared.libs.delete(self.real_name) if is_delete
    end
    LgPodPlugin.log_green "find the cache of `#{name}`, you can use it now."
  end

end