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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1772c80903e5f7a17d9c618d51a0096d185092af
4
- data.tar.gz: 1f7741bef9920363de9faa52be1398f0d9824b18
3
+ metadata.gz: a54b0308170f33c73a30ca35348c2b7c0029bf1e
4
+ data.tar.gz: deeff23b273884bceca64fc75a945bfd4c576e4e
5
5
  SHA512:
6
- metadata.gz: 1437df160da25f7ee1c5d2e33bee4924b6006d08ed0eceb4815d2886dfad0da1acb80ec1fc8f50224301faa62e3f6a8b2fb000d59337cc0e24ee6a6c1f077184
7
- data.tar.gz: 817f33cc8a346541b72ebe92c72b24a369d0d6fe4a616a0ae794ad26fbd97f80e0e1fbab36b7bf7eb95b346cadec3a52a28b9c6683857a6eb066ea33069aee05
6
+ metadata.gz: e26a00f7aae6919dd5277492d6cd86ef996c3412e0c6bb8f2fdea1fee644765ad71da80273a0e1fa1fc61fdf25cbb29c55a05094e82c7e671a202e3ca5c77885
7
+ data.tar.gz: b95fc1fad0f148eddd1d54415f912b9ed039c59199fc67bbdd9631a22d956192aebcfa562b030ad646323d08ae6984a45648bc64215bc2a04fe42047a18193ec
@@ -1,3 +1,3 @@
1
1
  module CocoapodsPruneLocalizations
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.section 'Pruning unused localizations' do
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
- resGroup = group["Resources"]
38
- next unless resGroup
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
- resGroup.files.each do |file|
43
- keep = true
44
- if file.path.end_with? ".lproj"
45
- keep = langs_to_keep.include?(File.basename(file.path))
46
- elsif file.path.end_with? ".bundle"
47
- trimmed_bundle = self.trimmed_bundle(file.real_path)
48
- if trimmed_bundle
49
- trimmedBundlesToAdd[file.real_path] = trimmed_bundle
50
- keep = false
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
- if !keep
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
- group_path = File.join(@pruned_bundles_path, group.path)
81
- FileUtils.mkdir group_path unless Dir.exist? group_path
82
- Pod::UI.message "Adding trimmed bundles to #{group.path}" do
83
- trimmedBundlesToAdd.each_pair do |original_bundle_path, bundle_path|
84
- bundle_name = File.basename(original_bundle_path)
85
- new_bundle_path = File.join(group_path, bundle_name)
86
- FileUtils.rm_r(new_bundle_path) if File.exist? new_bundle_path
87
- FileUtils.mv(bundle_path, new_bundle_path)
88
- group.new_reference(new_bundle_path)
89
-
90
- relative_path = original_bundle_path.relative_path_from(@sandbox_root).to_s
91
- new_relative_path = Pathname.new(new_bundle_path).relative_path_from(@sandbox_root).to_s
92
- rsrc_scripts_files.each_value do |lines|
93
- for i in 0...lines.length
94
- lines[i] = lines[i].gsub(relative_path, new_relative_path)
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.0
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-22 00:00:00.000000000 Z
11
+ date: 2015-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler