cocoapods-prune-localizations 0.1.0 → 0.1.1
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-prune-localizations.rb +1 -1
- data/lib/pruner.rb +48 -33
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a54b0308170f33c73a30ca35348c2b7c0029bf1e
|
4
|
+
data.tar.gz: deeff23b273884bceca64fc75a945bfd4c576e4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e26a00f7aae6919dd5277492d6cd86ef996c3412e0c6bb8f2fdea1fee644765ad71da80273a0e1fa1fc61fdf25cbb29c55a05094e82c7e671a202e3ca5c77885
|
7
|
+
data.tar.gz: b95fc1fad0f148eddd1d54415f912b9ed039c59199fc67bbdd9631a22d956192aebcfa562b030ad646323d08ae6984a45648bc64215bc2a04fe42047a18193ec
|
data/lib/pruner.rb
CHANGED
@@ -29,36 +29,49 @@ module CocoapodsPruneLocalizations
|
|
29
29
|
end
|
30
30
|
|
31
31
|
langs_to_keep = @user_options["localizations"] || []
|
32
|
-
Pod::UI.
|
32
|
+
Pod::UI.title 'Pruning unused localizations' do
|
33
|
+
|
34
|
+
#Group all the Pods
|
33
35
|
pod_groups = @pod_project["Pods"].children.objects
|
34
36
|
dev_pod_group = @pod_project["Development Pods"]
|
35
37
|
pod_groups += dev_pod_group.children.objects if dev_pod_group
|
38
|
+
|
36
39
|
pod_groups.each do |group|
|
37
|
-
|
38
|
-
|
40
|
+
|
41
|
+
#Gather all Resources groups
|
42
|
+
resGroups = group.recursive_children_groups.select do |group|
|
43
|
+
group.name == "Resources"
|
44
|
+
end
|
45
|
+
next unless resGroups.length > 0
|
39
46
|
|
40
47
|
markForRemoval = []
|
41
48
|
trimmedBundlesToAdd = Hash.new
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
|
50
|
+
resGroups.each do |resGroup|
|
51
|
+
subTrimmedBundlesToAdd = Hash.new
|
52
|
+
resGroup.files.each do |file|
|
53
|
+
keep = true
|
54
|
+
if file.path.end_with? ".lproj"
|
55
|
+
keep = langs_to_keep.include?(File.basename(file.path))
|
56
|
+
elsif file.path.end_with? ".bundle"
|
57
|
+
trimmed_bundle = self.trimmed_bundle(file.real_path)
|
58
|
+
if trimmed_bundle
|
59
|
+
subTrimmedBundlesToAdd[file.real_path] = trimmed_bundle
|
60
|
+
keep = false
|
61
|
+
end
|
62
|
+
end
|
63
|
+
if !keep
|
64
|
+
markForRemoval << file
|
51
65
|
end
|
52
66
|
end
|
53
|
-
|
54
|
-
markForRemoval << file
|
55
|
-
end
|
67
|
+
trimmedBundlesToAdd[resGroup] = subTrimmedBundlesToAdd unless subTrimmedBundlesToAdd.length == 0
|
56
68
|
end
|
57
|
-
|
69
|
+
|
70
|
+
#Remove file references indentified for removal
|
58
71
|
if markForRemoval.length > 0
|
59
72
|
Pod::UI.section "Pruning in #{group.path}" do
|
60
73
|
markForRemoval.each do |file|
|
61
|
-
Pod::UI.message "Pruning #{file}"
|
74
|
+
Pod::UI.message "- Pruning #{file}"
|
62
75
|
|
63
76
|
unless file.path.end_with? ".bundle"
|
64
77
|
relative_path = file.real_path.relative_path_from @sandbox_root
|
@@ -75,23 +88,25 @@ module CocoapodsPruneLocalizations
|
|
75
88
|
end
|
76
89
|
end
|
77
90
|
end
|
78
|
-
|
91
|
+
|
79
92
|
if trimmedBundlesToAdd.length > 0
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
trimmedBundlesToAdd.each_pair do |
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
93
|
+
Pod::UI.section "Adding trimmed bundles to #{group.path}" do
|
94
|
+
group_path = File.join(@pruned_bundles_path, group.path)
|
95
|
+
FileUtils.mkdir group_path unless Dir.exist? group_path
|
96
|
+
trimmedBundlesToAdd.each_pair do |resGroup, bundleArray|
|
97
|
+
bundleArray.each_pair do |original_bundle_path, bundle_path|
|
98
|
+
bundle_name = File.basename(original_bundle_path)
|
99
|
+
new_bundle_path = File.join(group_path, bundle_name)
|
100
|
+
FileUtils.rm_r(new_bundle_path) if File.exist? new_bundle_path
|
101
|
+
FileUtils.mv(bundle_path, new_bundle_path)
|
102
|
+
resGroup.new_reference(new_bundle_path)
|
103
|
+
|
104
|
+
relative_path = original_bundle_path.relative_path_from(@sandbox_root).to_s
|
105
|
+
new_relative_path = Pathname.new(new_bundle_path).relative_path_from(@sandbox_root).to_s
|
106
|
+
rsrc_scripts_files.each_value do |lines|
|
107
|
+
for i in 0...lines.length
|
108
|
+
lines[i] = lines[i].gsub(relative_path, new_relative_path)
|
109
|
+
end
|
95
110
|
end
|
96
111
|
end
|
97
112
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-prune-localizations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Diego Torres
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|