Class: LgPodPlugin::ReleasePod

Inherits:
Object
  • Object
show all
Defined in:
lib/lg_pod_plugin/release-pod.rb

Class Method Summary collapse

Class Method Details

.dependencies(installer) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/lg_pod_plugin/release-pod.rb', line 45

def self.dependencies(installer)
  installer.download_dependencies
  installer.send(:validate_targets)
  installation_options = installer.send(:installation_options)
  skip_pods_project_generation = installation_options.send(:skip_pods_project_generation)
  if skip_pods_project_generation
    installer.show_skip_pods_project_generation_message
  else
    installer.integrate
  end
  installer.send(:write_lockfiles)
  installer.send(:perform_post_install_actions)
end

.install_release_pod(work_space, podfile, repo_update, update, external_pods, local_pods) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/lg_pod_plugin/release-pod.rb', line 59

def self.install_release_pod(work_space, podfile, repo_update, update, external_pods, local_pods)
  #切换工作目录到当前工程下, 开始执行pod install
  FileUtils.chdir(work_space)
  # 安装 relase_pod
  LgPodPlugin.log_green "Pre-downloading Release Pods"
  Pod::Config.instance.verbose = true
  pods_path = work_space.join('Pods')
  lockfile_path = work_space.join("Podfile.lock")
  lock_file = Pod::Lockfile.from_file(lockfile_path) if lockfile_path.exist?
  sandobx = Pod::Sandbox.new(pods_path)
  installer = Pod::Installer.new(sandobx, podfile, lock_file)
  installer.repo_update = repo_update
  if update
    if external_pods.empty?
      installer.update = true
    else
      pods =  LRequest.shared.libs.merge!(local_pods)
      installer.update = { :pods => pods.keys}
    end
  else
    installer.update = false
  end
  installer.deployment = false
  installer.clean_install = false
  installer.prepare
  resolve_dependencies(work_space, podfile, lock_file, installer, external_pods)
  dependencies(installer)
end

.resolve_dependencies(work_space, podfile, lockfile, installer, external_pods) ⇒ Object



10
11
12
13
14
15
16
17
18
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
# File 'lib/lg_pod_plugin/release-pod.rb', line 10

def self.resolve_dependencies(work_space, podfile, lockfile, installer, external_pods)
  installer.resolve_dependencies
  analysis_result = installer.send(:analysis_result)
  return unless analysis_result
  root_specs = analysis_result.specifications.map(&:root).uniq
  root_specs = root_specs.reject! do |spec|
    spec_name = spec.send(:attributes_hash)["name"]
    external_pods[spec_name] || external_pods[spec_name.split("/").first]
  end unless external_pods.empty?
  return unless root_specs
  root_specs.sort_by(&:name).each do |spec|
    attributes_hash = spec.send(:attributes_hash)
    next unless attributes_hash.is_a?(Hash)
    pod_name = attributes_hash["name"]
    checksum = spec.send(:checksum)
    if lockfile && checksum
      internal_data = lockfile.send(:internal_data)
      lock_checksums = internal_data["SPEC CHECKSUMS"] ||= {}
      lock_checksum = lock_checksums[pod_name]
      next if lock_checksum == checksum
    end
    pod_version = attributes_hash["version"]
    source = attributes_hash['source']
    next unless source.is_a?(Hash)
    git = source["git"]
    tag = source["tag"]
    next unless (git && tag) && (git.include?("https://github.com"))
    requirements = { :git => git, :tag => tag, :release_pod => true, :spec => spec}
    LRequest.shared.checkout_options = requirements
    next unless LCache.new(work_space).find_pod_cache(pod_name, { :git => git, :tag => tag })
    LgPodPlugin::Installer.new(podfile, pod_name, requirements)
  end

end