cocoapods-prune-localizations 0.1.1 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a54b0308170f33c73a30ca35348c2b7c0029bf1e
4
- data.tar.gz: deeff23b273884bceca64fc75a945bfd4c576e4e
3
+ metadata.gz: a524a5c962c69f32e555919e3448f03da9c31acf
4
+ data.tar.gz: 7e26a83aac8d9042fa681b585b8fb077a690d1d6
5
5
  SHA512:
6
- metadata.gz: e26a00f7aae6919dd5277492d6cd86ef996c3412e0c6bb8f2fdea1fee644765ad71da80273a0e1fa1fc61fdf25cbb29c55a05094e82c7e671a202e3ca5c77885
7
- data.tar.gz: b95fc1fad0f148eddd1d54415f912b9ed039c59199fc67bbdd9631a22d956192aebcfa562b030ad646323d08ae6984a45648bc64215bc2a04fe42047a18193ec
6
+ metadata.gz: 9d2813acac786ac52d5b626260e4e0b309cc77f97bcdbc4f8f515c360af8303f63266c464281330f7e3d86f1bc2a7a8531a0bd43fba4f639335cb16eee605473
7
+ data.tar.gz: ad16293b91d376e3464bc6702b44edefae4f21bf9974e3f4dd8700e86e8da8526f3fb8fdd810d2c6962985a805f48afaefb5366a80b063bbbcb9920d7d93d185
data/README.md CHANGED
@@ -1,6 +1,12 @@
1
- # cocoapods-prune-localizations
1
+ # Prune Localizations
2
2
 
3
- This plugin allows you to remove unused localizations provided by the Pods you depend on.
3
+ This plugin removes unused localized files from your app.
4
+
5
+ Localized resources provided by third parties increase the size of your app and keeping resources your app will never use only bloats it.
6
+
7
+ ##Requirements
8
+
9
+ Requires CocoaPods 0.36
4
10
 
5
11
  ## Installation
6
12
 
@@ -10,6 +16,15 @@ This plugin allows you to remove unused localizations provided by the Pods you d
10
16
 
11
17
  In your Podfile, add this line:
12
18
 
13
- plugin 'cocoapods-prune-localizations', {:localizations => ["en.lproj", "es.lproj"]}
19
+ plugin 'cocoapods-prune-localizations', {:localizations => ["en", "es"]}
20
+
21
+ This will keep the English and Spanish localizations in the Pods. Modify the localizations to your needs.
22
+
23
+ ##How it works
24
+
25
+ The plugin traverses the resources provided by Pods and removes references in the Xcode project of `.lproj` files that don't match the list provided.
26
+
27
+ A special case are `.bundle` file references because they are a [package](http://en.wikipedia.org/wiki/Package_(OS_X)) of different resources. As such, if any localized files are found unnecessary, a new bundle is created without those files and replaces the original in the project. These new bundles are located at `Pods/Pruned Localized Bundles`
28
+
29
+ **Note:** No file is actually removed from your computer, only references to them in the project
14
30
 
15
- This will keep the English and Spanish localizations in the Pods. Modify the localizations to your needs.
@@ -1,3 +1,3 @@
1
1
  module CocoapodsPruneLocalizations
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/pruner.rb CHANGED
@@ -1,15 +1,31 @@
1
- require "FileUtils"
1
+ require_relative 'utils'
2
2
 
3
3
  module CocoapodsPruneLocalizations
4
4
  class Pruner
5
5
  def initialize(context, user_options)
6
6
  @sandbox_root = Pathname.new context.sandbox_root
7
7
  @pod_project = Xcodeproj::Project.open File.join(context.sandbox_root, 'Pods.xcodeproj')
8
- @user_options = user_options
8
+ @user_options = self.class.user_options(context, user_options)
9
9
  @pruned_bundles_path = File.join(context.sandbox_root, "Pruned Localized Bundles")
10
10
  FileUtils.mkdir @pruned_bundles_path unless Dir.exist? @pruned_bundles_path
11
11
  end
12
12
 
13
+ def self.user_options(context, orig_user_opts = {})
14
+ user_options = {}
15
+ if orig_user_opts["localizations"]
16
+ user_options["localizations"] = orig_user_opts["localizations"].map do |loc|
17
+ if loc.end_with? ".lproj"
18
+ loc
19
+ else
20
+ loc + ".lproj"
21
+ end
22
+ end
23
+ else
24
+ user_options["localizations"] = Utils.user_project_localizations(context.umbrella_targets)
25
+ end
26
+ user_options
27
+ end
28
+
13
29
  def resources_scripts(group)
14
30
  file_references = []
15
31
  group.children.objects.each do |children|
data/lib/utils.rb ADDED
@@ -0,0 +1,21 @@
1
+ module CocoapodsPruneLocalizations
2
+ class Utils
3
+ def self.user_project_localizations(umbrella_targets)
4
+ localizations = []
5
+ user_projects = umbrella_targets.map { |target| target.user_project_path }
6
+ user_projects.uniq!
7
+
8
+ user_projects.each do |project_path|
9
+ project = Xcodeproj::Project.open project_path
10
+ project.files.each do |file_ref|
11
+ if file_ref.path.include? ".lproj"
12
+ localizations << File.dirname(file_ref.path)
13
+ end
14
+ end
15
+ end
16
+
17
+ localizations.uniq!
18
+ localizations
19
+ end
20
+ end
21
+ 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.1
4
+ version: 0.2.0
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-23 00:00:00.000000000 Z
11
+ date: 2015-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -54,6 +54,7 @@ files:
54
54
  - lib/cocoapods-prune-localizations.rb
55
55
  - lib/cocoapods_plugin.rb
56
56
  - lib/pruner.rb
57
+ - lib/utils.rb
57
58
  homepage: https://github.com/dtorres/cocoapods-prune-localizations
58
59
  licenses:
59
60
  - MIT