Class: LgPodPlugin::ReleasePod
Instance Attribute Summary
Attributes inherited from ExternalPod
#checkout_options, #name, #released_pod, #spec, #target
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(target, name, hash, spec) ⇒ ReleasePod
Returns a new instance of ReleasePod.
9
10
11
12
13
14
15
|
# File 'lib/lg_pod_plugin/pod/release-pod.rb', line 9
def initialize(target, name, hash, spec)
@spec = spec
@name = name
@target = target
@released_pod = true
@checkout_options = hash
end
|
Class Method Details
.check_release_pod_exist(name, requirements, spec, released_pod) ⇒ Object
17
18
19
20
|
# File 'lib/lg_pod_plugin/pod/release-pod.rb', line 17
def self.check_release_pod_exist(name, requirements, spec, released_pod)
is_exist, _, _ = (LCache.new.pod_cache_exist(name, requirements, spec, released_pod))
return is_exist
end
|
.dependencies(installer) ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/lg_pod_plugin/pod/release-pod.rb', line 77
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)
write_podfile_lock
write_manifest_lock
end
|
.install_release_pod(update, repo_update, verbose) ⇒ Object
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
# File 'lib/lg_pod_plugin/pod/release-pod.rb', line 141
def self.install_release_pod(update, repo_update, verbose)
workspace = LProject.shared.workspace
FileUtils.chdir(workspace)
LgPodPlugin.log_blue "Pre-downloading Release Pods"
Pod::Config.instance.verbose = verbose
pods_path = LProject.shared.workspace.join('Pods')
podfile = LProject.shared.podfile
lockfile = LProject.shared.lockfile
sandbox = Pod::Sandbox.new(pods_path)
installer = Pod::Installer.new(sandbox, podfile, lockfile)
installer.repo_update = repo_update
if update
need_update_pods = LProject.shared.need_update_pods ||= Hash.new
pods = need_update_pods.keys ||= []
begin
verify_lockfile_exists!(lockfile)
verify_pods_are_installed!(pods, lockfile)
internal_data = lockfile.send(:internal_data)
flag = internal_data["LOCKFILE TYPE"]
if flag != nil
if pods.empty?
installer.update = true
else
installer.update = { :pods => pods }
end
else
installer.update = false
end
rescue
installer.update = false
end
else
installer.update = false
end
installer.deployment = false
installer.clean_install = false
installer.prepare
resolve_dependencies(lockfile, installer)
dependencies(installer)
end
|
.lockfile_missing_pods(pods, lockfile) ⇒ Object
113
114
115
116
|
# File 'lib/lg_pod_plugin/pod/release-pod.rb', line 113
def self.lockfile_missing_pods(pods, lockfile)
lockfile_roots = lockfile.pod_names.map { |pod| Pod::Specification.root_name(pod) }
pods.map { |pod| Pod::Specification.root_name(pod) }.uniq - lockfile_roots
end
|
.resolve_dependencies(lockfile, installer) ⇒ Object
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
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/lg_pod_plugin/pod/release-pod.rb', line 22
def self.resolve_dependencies(lockfile, installer)
installer.resolve_dependencies
external_pods = LProject.shared.external_pods ||= {}
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
all_installers = Array.new
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"]
source = attributes_hash['source']
next unless source.is_a?(Hash)
git = source["git"]
tag = source["tag"]
http = source["http"]
checksum = spec.send(:checksum)
if http
if http.include?("https://github.com") && http.include?("releases/download")
http = "https://ghproxy.com/" + http
source["http"] = http
end
version = attributes_hash["version"]
requirements = {:http => http, :version => version}
elsif git && tag
tag = tag.to_s unless LUtils.is_a_string? tag
requirements = { :git => git, :tag => tag }
else
next
end
pod_exist = check_release_pod_exist(pod_name, requirements, spec, true)
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) && (pod_exist)
else
next if pod_exist
end
LProject.shared.cache_specs[pod_name] = spec
lg_spec = LgPodPlugin::PodSpec.form_pod_spec spec
release_pod = ReleasePod.new(nil, pod_name, requirements, lg_spec)
pod_install = LgPodPlugin::LPodInstaller.new
download_params = pod_install.install(release_pod)
all_installers.append pod_install if download_params
end
LgPodPlugin::Concurrency.async_download_pods all_installers
end
|
.verify_lockfile_exists!(lockfile) ⇒ Object
135
136
137
138
139
|
# File 'lib/lg_pod_plugin/pod/release-pod.rb', line 135
def self.verify_lockfile_exists!(lockfile)
unless lockfile
raise Pod::Informative, "No `Podfile.lock' found in the project directory, run `pod install'."
end
end
|
.verify_pods_are_installed!(pods, lockfile) ⇒ Object
Check if all given pods are installed
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
# File 'lib/lg_pod_plugin/pod/release-pod.rb', line 120
def self.verify_pods_are_installed!(pods, lockfile)
missing_pods = lockfile_missing_pods(pods, lockfile)
unless missing_pods.empty?
message = if missing_pods.length > 1
"Pods `#{missing_pods.join('`, `')}` are not " \
'installed and cannot be updated'
else
"The `#{missing_pods.first}` Pod is not installed " \
'and cannot be updated'
end
raise Pod::Informative, message
end
end
|
.write_manifest_lock ⇒ Object
103
104
105
106
107
108
109
110
111
|
# File 'lib/lg_pod_plugin/pod/release-pod.rb', line 103
def self.write_manifest_lock
lockfile_path = LProject.shared.workspace.join("Pods").join("Manifest.lock")
lockfile = Pod::Lockfile.from_file(lockfile_path) if lockfile_path.exist?
return unless lockfile
hash = lockfile.send(:internal_data)
hash["LOCKFILE TYPE"] = "LgPodPlugin"
lockfile_path = lockfile.send(:defined_in_file)
lockfile.send(:write_to_disk, lockfile_path)
end
|
.write_podfile_lock ⇒ Object
93
94
95
96
97
98
99
100
101
|
# File 'lib/lg_pod_plugin/pod/release-pod.rb', line 93
def self.write_podfile_lock
lockfile_path = LProject.shared.workspace.join("Podfile.lock")
lockfile = Pod::Lockfile.from_file(lockfile_path) if lockfile_path.exist?
return unless lockfile
hash = lockfile.send(:internal_data)
hash["LOCKFILE TYPE"] = "LgPodPlugin"
lockfile_path = lockfile.send(:defined_in_file)
lockfile.send(:write_to_disk, lockfile_path)
end
|