xcodeproj_utils 0.1.4 → 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: 55ee7bd293b3431e5b6f11f9f558f92eafb94364
4
- data.tar.gz: e150d188075d3778de4bf57161adc7b8730368e4
3
+ metadata.gz: d8bd072ef293b206fe30b0b191a5ae30cb92c474
4
+ data.tar.gz: dcb1229a9f4dd94050a74230222e3ae4d56152a7
5
5
  SHA512:
6
- metadata.gz: 47560fe8914a3eac5d6984a28cc52a436851568d466e9ad63fab257c7816001f5bed463e91291c7e9dac074119c4dc9cdc32e681e788823dbac93500376404d2
7
- data.tar.gz: d73e4b7ed8075940f201207b334057d500398f445adaa907012ef8d604f09e2caa054d8e1adba338492553d0dee32c9abf2a8e82bd3371dcc1118f83a95f2f36
6
+ metadata.gz: bb5f27a321695e4b5f9393fd3ecec24036b521ec1a2a1c294966f28b43c235291dbba398970f3d0cdb0aca51a4f7740db45717461bda4ce2a2bb7bec97a0991a
7
+ data.tar.gz: 210c9def213ac2c254e43ff4953859982addc2e615ea0285cc376d6223238feeeecdb18aeb42c06afb38e33215ebceb063e4ba3defed17004bf13d7a34f3b1f1
data/README.md CHANGED
@@ -7,6 +7,7 @@ Util commands for xcode project. Following commands are supported for now.
7
7
 
8
8
  - Count source lines of files in xcode project
9
9
  - Show source / resource files in xcode project
10
+ - Show possibly unused images in xcode project
10
11
 
11
12
  ## Installation
12
13
 
@@ -27,6 +28,7 @@ Or install it yourself as:
27
28
  $ xcp_utils lines <PATH_TO_XCODE_PROJECT> <TARGET_NAME>
28
29
  $ xcp_utils lines --header_only <PATH_TO_XCODE_PROJECT> <TARGET_NAME>
29
30
  $ xcp_utils lines --source_only <PATH_TO_XCODE_PROJECT> <TARGET_NAME>
31
+ $ xcp_utils unused_images <PATH_TO_XCODE_PROJECT> <TARGET_NAME>
30
32
 
31
33
  ## License
32
34
 
data/bin/xcp_utils CHANGED
@@ -4,7 +4,7 @@ require 'thor'
4
4
  require 'xcodeproj_utils'
5
5
 
6
6
  class CLI < Thor
7
- desc "xcp_utils lines PROJECT_NAME TARGET_NAME", "Count source lines of files"
7
+ desc "xcp_utils lines PROJECT_PATH TARGET_NAME", "Count source lines of files"
8
8
  option :header_only, :type => :boolean, :default => false, :desc => 'Count only header files'
9
9
  option :source_only, :type => :boolean, :default => false, :desc => 'Count only source files'
10
10
  def lines(proj_name, target_name)
@@ -18,7 +18,7 @@ class CLI < Thor
18
18
  end
19
19
  end
20
20
 
21
- desc "xcp_utils show PROJECT_NAME TARGET_NAME", "Show files in specified target"
21
+ desc "xcp_utils show PROJECT_PATH TARGET_NAME", "Show files in specified target"
22
22
  option :kind, :type => :string, :default => 'source', :desc => 'source or resource'
23
23
  option :fullpath, :type => :boolean, :default => false, :desc => 'full paths will be shown if specified'
24
24
  def show(proj_name, target_name)
@@ -27,6 +27,15 @@ class CLI < Thor
27
27
  proj = XcodeprojUtils::Project.new(proj_name, target_name)
28
28
  proj.show(kind, fullpath)
29
29
  end
30
+
31
+ desc "xcp_utils unused_images PROJECT_PATH TARGET_NAME", "Show unused images"
32
+ def unused_images(proj_name, target_name)
33
+ proj = XcodeprojUtils::Project.new(proj_name, target_name)
34
+ for image in proj.search_unused_images
35
+ puts image.display_name
36
+ end
37
+ end
38
+
30
39
  end
31
40
 
32
41
  CLI.start(ARGV)
@@ -1,3 +1,3 @@
1
1
  module XcodeprojUtils
2
- VERSION = "0.1.4"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -62,5 +62,28 @@ module XcodeprojUtils
62
62
  end
63
63
  return nil
64
64
  end
65
+
66
+ def search_unused_images
67
+ sources = ""
68
+ for file in @target.source_build_phase.files_references
69
+ sources += File.read file.real_path
70
+ end
71
+
72
+ images = []
73
+ for file in @target.resources_build_phase.files_references
74
+ if not file.last_known_file_type or not file.last_known_file_type.match /^image/
75
+ next
76
+ end
77
+
78
+ name = File.basename(file.display_name, '.*')
79
+ name = name.split('@').first
80
+
81
+ if sources.scan(name).count == 0
82
+ images << file
83
+ end
84
+ end
85
+
86
+ images.sort {|x,y| x.display_name <=> y.display_name}
87
+ end
65
88
  end
66
89
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcodeproj_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matsumoto Taichi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-17 00:00:00.000000000 Z
11
+ date: 2014-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler