Class: LgPodPlugin::Installer

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

Instance Method Summary collapse

Constructor Details

#initialize(profile, name, requirements) ⇒ Installer

Returns a new instance of Installer.



19
20
21
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
54
55
56
57
58
59
60
61
62
# File 'lib/lg_pod_plugin/install.rb', line 19

def initialize(profile, name, requirements)
  unless name
    raise StandardError, 'A dependency requires a name.'
  end
  if name.include?("/")
    self.name = name.split("/").first
  else
    self.name = name
  end
  self.real_name = name
  self.workspace = profile.send(:defined_in_file).dirname
  self.target = profile.send(:current_target_definition)
  unless requirements && requirements.is_a?(Hash)
    LRequest.shared.libs.delete(name)
    LRequest.shared.libs.delete(self.real_name)
    LgPodPlugin.log_red "pod `#{name}`, 缺少必要的 [git|commit|tag|branch] 参数"
    return
  end
  git = requirements[:git]
  tag = requirements[:tag]
  commit = requirements[:commit]
  branch = requirements[:branch]
  hash_map = Hash.new.merge!(requirements)
  if git
    if tag
      hash_map.delete(:branch)
      hash_map.delete(:commit)
    elsif commit
      hash_map.delete(:tag)
      hash_map.delete(:branch)
    elsif branch
      hash_map.delete(:tag)
      hash_map.delete(:commit)
    else
      hash_map.delete(:tag)
      hash_map.delete(:branch)
      hash_map.delete(:commit)
    end
  end
  self.options = hash_map
  LRequest.shared.setup_pod_info(self.name, self.workspace, hash_map)
  LRequest.shared.downloader.real_name = self.real_name
  self.install_remote_pod(name, hash_map)
end

Instance Method Details

#install_remote_pod(name, options = {}) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/lg_pod_plugin/install.rb', line 65

def install_remote_pod(name, options = {})
  git = options[:git]
  if git
    if LRequest.shared.net_ping && LRequest.shared.net_ping.ip && LRequest.shared.net_ping.network_ok
      LRequest.shared.downloader.pre_download_pod
    else
      LgPodPlugin.log_red "请求#{git} 超时, 下载失败!"
    end
  else
    LRequest.shared.libs.delete(name)
    LRequest.shared.libs.delete(self.real_name)
    LgPodPlugin.log_red "pod `#{name}`, 缺少必要的 [git|commit|tag|branch] 参数"
  end
end