cocoapods-assets-cleaner 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
  SHA256:
3
- metadata.gz: daffc3fad0c10a0d7d73c5bdd20fa2a5eaa4c5592497a1b120e9e66feba2c227
4
- data.tar.gz: c3c641fc24f3aa3d99f4f8dda0dc79b0a697db739b68b899361f0fc51babed28
3
+ metadata.gz: f07df23fde04f26b20eabbf0b9ff5468349c11b5d06aba9a6f3e5437739918be
4
+ data.tar.gz: 569faf5b4c37e764c4f183b2f002d4710877bb8a068a3269272df5b3ed07333c
5
5
  SHA512:
6
- metadata.gz: 5e35be205096e24bb70debed5d45f86f8aed52b85faae1cfaa95d6ba7dc604e767b51101ef74cd1ef4e544cd8231a247471f4414e5c80e049d95589fe3ca7b44
7
- data.tar.gz: fdc502fdce00f7ec78d8272a9c53d654db583b02421062653d046a695bcc892709fa3b8db33399a0e419115927ad72b66bcadd27b9d4c4f82bc92b9340549f4e
6
+ metadata.gz: 5de60d9ee5f7f7ba4e45efa456cb9157ebb4bc9c8c6fbf58fe3deafafb5706d717737281ea37a86e735501dc86cd5b9a2ff0d287836972e37faab56645dc9a7a
7
+ data.tar.gz: 8e041d8b6eddb7a451477c323f635666e802814cc114af79269e6aa7d77987f4ae80a5ed2387e4f94bf808db1cb2605d856812fcb58accd5c5ab7d21b7e229aa
data/README.md CHANGED
@@ -32,3 +32,7 @@ Run `pod clean-unused-assets` command with `--assets-path` to indicate where is
32
32
  You can also define a specific directory for the plugin to search for unused assets. Just add `--project-path`:
33
33
 
34
34
  $ pod clean-unused-assets --assets-path=./path/to/Assets.xcassets --project-path=./optional/path/
35
+
36
+ Use `--exclude-dir` define a directory to exclude from asset use search. (default: {project-path - assets-path: Assets.xcassets}):
37
+
38
+ $ pod clean-unused-assets --assets-path=./path/to/Assets.xcassets --project-path=./optional/path/ --exclude-dir=path/to/exclude/dir/relative/to/projectpath
@@ -3,9 +3,10 @@ require "fileutils"
3
3
 
4
4
  module CocoapodsAssetsCleaner
5
5
  class AssetsCleaner
6
- def initialize(main_project_path_param, assets_path_param)
6
+ def initialize(main_project_path_param, assets_path_param, excluded_dir_param)
7
7
  @main_project_path = main_project_path_param
8
8
  @assets_path = assets_path_param
9
+ @excluded_dir = excluded_dir_param
9
10
 
10
11
  @spinner = Enumerator.new do |e|
11
12
  loop do
@@ -23,7 +24,7 @@ module CocoapodsAssetsCleaner
23
24
  Pod::UI.puts "#{imagesets.count} images founded"
24
25
 
25
26
  Pod::UI.puts "Searching for unused images...".yellow
26
- unused_imagesets = check_and_extact_unsed_images(imagesets, @main_project_path)
27
+ unused_imagesets = check_and_extact_unsed_images(imagesets, @main_project_path, @excluded_dir)
27
28
  Pod::UI.puts "#{unused_imagesets.count} unused images founded"
28
29
 
29
30
  Pod::UI.puts "Removing unused images...".yellow
@@ -33,7 +34,6 @@ module CocoapodsAssetsCleaner
33
34
 
34
35
  def show_indicator_percentage(i)
35
36
  printf("\r%d%% %s", i, @spinner.next)
36
- sleep(0.1)
37
37
  end
38
38
 
39
39
  def remove_unused_image(image_name, image_path)
@@ -47,12 +47,12 @@ module CocoapodsAssetsCleaner
47
47
  end
48
48
  end
49
49
 
50
- def check_and_extact_unsed_images(images, path)
50
+ def check_and_extact_unsed_images(images, path, excluded_dir)
51
51
  unused_images = {}
52
52
  count = 0
53
53
 
54
54
  images.each do |image_name, image_path|
55
- command_sh = `grep -R -l --exclude-dir=Assets.xcassets "#{image_name}" #{path}`
55
+ command_sh = `grep -R -l --exclude-dir=#{excluded_dir} "#{image_name}" #{path}`
56
56
  if command_sh == ""
57
57
  Pod::UI.puts "\r#{image_name} is not used.".yellow
58
58
  unused_images[image_name] = image_path
@@ -23,18 +23,25 @@ module Pod
23
23
  def self.options
24
24
  [
25
25
  ['--assets-path', 'Assets path'],
26
- ['--project-path', 'Projects path (default: ./)']
26
+ ['--project-path', 'Projects path (default: ./)'],
27
+ ['--exclude-dir', 'Define a directory to exclude from asset use search. (default: {project-path - assets-path: Assets.xcassets})']
27
28
  ].concat(super)
28
29
  end
29
30
 
30
31
  def initialize(argv)
31
32
  @assets_path = argv.option('assets-path')
32
33
  @project_path = argv.option('project-path', './')
34
+ @excluded_dir = argv.option('exclude-dir', 'Assets.xcassets')
33
35
  super
34
36
  end
35
37
 
36
38
  def run
37
- assets_cleaner = CocoapodsAssetsCleaner::AssetsCleaner.new(@project_path, @assets_path)
39
+ excluded_dir = @excluded_dir || @assets_path.gsub(@project_path, "")
40
+ if excluded_dir[0] == "/"
41
+ excluded_dir[0] = ""
42
+ end
43
+
44
+ assets_cleaner = CocoapodsAssetsCleaner::AssetsCleaner.new(@project_path, @assets_path, excluded_dir)
38
45
  assets_cleaner.init_clean()
39
46
  end
40
47
  end
@@ -1,3 +1,3 @@
1
1
  module CocoapodsAssetsCleaner
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-assets-cleaner
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
  - Leo Valentim
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-08 00:00:00.000000000 Z
11
+ date: 2019-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods