cocoapods-podfile_patch 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cocoapods-podfile_patch/gem_version.rb +1 -1
- data/lib/cocoapods-podfile_patch/podfile_patch.rb +33 -27
- data/lib/cocoapods_plugin.rb +13 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 458241a69c9825a176500aa680c5f3529c1565f6
|
4
|
+
data.tar.gz: 39348fff4a039b73f68ab1edb75be9b9ccfdebf5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 572effa83441d770ebe21c0596ae9f778d3f860744f2478addb3ea3480f808784d6c118174bdc5f23fdb6611528c27e72e769d09ed42d239456f34261bef279f
|
7
|
+
data.tar.gz: 5b5f96a44cfb9c67affb45c43e4a402ffaa489d2fb5d67b6a24501f2bde8a6dde90e593cf653aa4e19027b4a3fb8814e0ffcaca6e0cf4703e7d69074e2616b62
|
@@ -7,8 +7,12 @@ require 'set'
|
|
7
7
|
|
8
8
|
class PodfilePatch
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
ABSTRACT_PATCH_TARGET_NAME = "cocoapods-podfile_patch-fake-target"
|
11
|
+
|
12
|
+
|
13
|
+
def load_patch_target(podfile, patchfile_path)
|
14
|
+
|
15
|
+
# find patch file
|
12
16
|
patch_file_path = Pathname.new(patchfile_path)
|
13
17
|
if not patch_file_path.expand_path.file?
|
14
18
|
podfile_root_path = Pathname.new(podfile.defined_in_file).dirname
|
@@ -18,37 +22,42 @@ class PodfilePatch
|
|
18
22
|
Pod::UI.info "Podfile patch feature is enabled. (No patch file now.)"
|
19
23
|
return
|
20
24
|
end
|
25
|
+
|
26
|
+
# load patch file content. And add it to a abstract target
|
27
|
+
contents = File.read(patch_file_path)
|
28
|
+
podfile.target ABSTRACT_PATCH_TARGET_NAME do
|
29
|
+
podfile.instance_eval contents
|
30
|
+
end
|
31
|
+
|
32
|
+
# find the patch target and delete it in original podfile
|
33
|
+
root_target = podfile.root_target_definitions[0]
|
34
|
+
patch_target = root_target.children.find {|t| t.name == ABSTRACT_PATCH_TARGET_NAME }
|
35
|
+
root_target.children.delete(patch_target)
|
36
|
+
|
37
|
+
return patch_target
|
38
|
+
end
|
21
39
|
|
22
|
-
|
23
|
-
|
24
|
-
|
40
|
+
|
41
|
+
def merge_patch_and_original_podfile(podfile, patch_target)
|
42
|
+
|
43
|
+
root_target = podfile.root_target_definitions[0]
|
44
|
+
|
45
|
+
# merge patch_target and original_target
|
46
|
+
patch_target.name = root_target.name
|
47
|
+
merge_target_definitions_dependency(root_target, patch_target)
|
48
|
+
|
25
49
|
Pod::UI.titled_section "Podfile patch feature is enabled" do
|
26
50
|
next unless Pod::UI.config.verbose?
|
27
51
|
Pod::UI.section "Patchfile Info" do
|
28
|
-
self.print_podfile_raw_dependencies
|
52
|
+
self.print_podfile_raw_dependencies patch_target
|
29
53
|
end
|
30
54
|
Pod::UI.section "Modified Podfile Info" do
|
31
|
-
self.print_podfile_raw_dependencies
|
55
|
+
self.print_podfile_raw_dependencies root_target
|
32
56
|
end
|
33
57
|
end
|
34
58
|
end
|
35
59
|
|
36
60
|
|
37
|
-
|
38
|
-
def patchfile(patch_file_path) # [Podfile]
|
39
|
-
Pod::Podfile.from_ruby(patch_file_path)
|
40
|
-
end
|
41
|
-
|
42
|
-
def patch(podfile:, with_podfile: )
|
43
|
-
original = podfile
|
44
|
-
patch = with_podfile
|
45
|
-
|
46
|
-
merge_target_definitions_dependency(
|
47
|
-
podfile.root_target_definitions[0],
|
48
|
-
patch.root_target_definitions[0]
|
49
|
-
)
|
50
|
-
end
|
51
|
-
|
52
61
|
def merge_target_definitions_dependency(targetdef, patch_targetdef)
|
53
62
|
# Demo Data
|
54
63
|
# Original Target
|
@@ -224,7 +233,7 @@ class PodfilePatch
|
|
224
233
|
end
|
225
234
|
end
|
226
235
|
|
227
|
-
def print_podfile_raw_dependencies(
|
236
|
+
def print_podfile_raw_dependencies(target)
|
228
237
|
|
229
238
|
def print_target_def_and_its_dependencies(target_def, intend = "")
|
230
239
|
puts "|\n"
|
@@ -235,10 +244,7 @@ class PodfilePatch
|
|
235
244
|
print_target_def_and_its_dependencies(target_def, intend + " ")
|
236
245
|
end
|
237
246
|
end
|
238
|
-
|
239
|
-
podfile.root_target_definitions.each do |target_def|
|
240
|
-
print_target_def_and_its_dependencies(target_def)
|
241
|
-
end
|
247
|
+
print_target_def_and_its_dependencies(target)
|
242
248
|
end
|
243
249
|
end
|
244
250
|
|
data/lib/cocoapods_plugin.rb
CHANGED
@@ -38,13 +38,18 @@ module Pod
|
|
38
38
|
# you do in podfile, i.e. your custom pod function or other plugins.
|
39
39
|
#
|
40
40
|
def use_patch_file!(patchfile_path = 'Podfile.patch')
|
41
|
-
|
42
|
-
@
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
41
|
+
|
42
|
+
@current_patch_files ||= []
|
43
|
+
if @current_patch_files.include? patchfile_path
|
44
|
+
# Yes, you could even use it recureively, but don't use the same patch file.
|
45
|
+
raise "`use_patch_file!` called recursively. Most case is it's used in Patch file."
|
46
|
+
return
|
47
47
|
end
|
48
|
+
|
49
|
+
@current_patch_files << patchfile_path
|
50
|
+
require 'cocoapods-podfile_patch/podfile_patch'
|
51
|
+
@patch_target = PodfilePatch.new.load_patch_target self, patchfile_path
|
52
|
+
@current_patch_files.delete(patchfile_path)
|
48
53
|
end
|
49
54
|
|
50
55
|
end
|
@@ -57,10 +62,8 @@ module Pod
|
|
57
62
|
define_method(:initialize) do |defined_in_file = nil, internal_hash = {}, &block|
|
58
63
|
old_initialize_function.bind(self).(defined_in_file, internal_hash, &block)
|
59
64
|
|
60
|
-
if @
|
61
|
-
|
62
|
-
patcher = PodfilePatch.new
|
63
|
-
patcher.main(self, @patchfile_path)
|
65
|
+
if not @patch_target.nil?
|
66
|
+
PodfilePatch.new.merge_patch_and_original_podfile(self, @patch_target)
|
64
67
|
end
|
65
68
|
end
|
66
69
|
end
|