xcodeproj_utils 0.0.2 → 0.1.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 +4 -4
- data/README.md +4 -1
- data/bin/xcp_utils +14 -3
- data/lib/xcodeproj_utils.rb +51 -32
- data/lib/xcodeproj_utils/version.rb +1 -1
- data/xcodeproj_utils.gemspec +9 -4
- metadata +17 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efebdccabae14fb48580fce9c3f80647d91193c8
|
4
|
+
data.tar.gz: c77bc9c825766a609d8ca298799bf4341825fc36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 511a0932548cbcf6c174af77376a286c59e21c84c7a904207955302aae4ed66dff03ebfe956b99356db331a6064b3566c186c788497b3776f2706174acfe5975
|
7
|
+
data.tar.gz: 239b1bdcc5308320f836dd70a6c90c2683df23babd3449ced2b399c95bcbb81ee7399a0056e636a7d2dd6de9bb557c3b7a22a9e358b0f617b4eb5fa49b2aaa52
|
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# XcodeprojUtils
|
2
2
|
|
3
|
-
|
3
|
+
Util commands for xcode project. Following commands are supported for now.
|
4
|
+
|
5
|
+
- Count source lines of files in xcode project
|
6
|
+
- Show source / resource files in xcode project
|
4
7
|
|
5
8
|
## Installation
|
6
9
|
|
data/bin/xcp_utils
CHANGED
@@ -4,18 +4,29 @@ require 'thor'
|
|
4
4
|
require 'xcodeproj_utils'
|
5
5
|
|
6
6
|
class CLI < Thor
|
7
|
-
desc "
|
7
|
+
desc "xcp_utils lines PROJECT_NAME 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)
|
11
11
|
header_only = options[:header_only]
|
12
12
|
source_only = options[:source_only]
|
13
|
+
proj = XcodeprojUtils::Project.new(proj_name, target_name)
|
13
14
|
if header_only or source_only
|
14
|
-
puts
|
15
|
+
puts proj.wc(header_only=header_only, source_only=source_only)
|
15
16
|
else
|
16
|
-
puts
|
17
|
+
puts proj.wc()
|
17
18
|
end
|
18
19
|
end
|
20
|
+
|
21
|
+
desc "xcp_utils show PROJECT_NAME TARGET_NAME", "Show files in specified target"
|
22
|
+
option :kind, :type => :string, :default => 'source', :desc => 'source or resource'
|
23
|
+
option :fullpath, :type => :boolean, :default => false, :desc => 'full paths will be shown if specified'
|
24
|
+
def show(proj_name, target_name)
|
25
|
+
kind = options[:kind]
|
26
|
+
fullpath = options[:fullpath]
|
27
|
+
proj = XcodeprojUtils::Project.new(proj_name, target_name)
|
28
|
+
proj.show(kind, fullpath)
|
29
|
+
end
|
19
30
|
end
|
20
31
|
|
21
32
|
CLI.start(ARGV)
|
data/lib/xcodeproj_utils.rb
CHANGED
@@ -2,47 +2,66 @@ require "xcodeproj_utils/version"
|
|
2
2
|
require "Xcodeproj"
|
3
3
|
|
4
4
|
module XcodeprojUtils
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
class Project
|
6
|
+
def initialize(proj_name, target_name)
|
7
|
+
@proj = Xcodeproj::Project::open(proj_name)
|
8
|
+
for t in @proj.targets
|
9
|
+
next if t.name != target_name
|
10
|
+
@target = t
|
11
|
+
break
|
12
|
+
end
|
13
|
+
raise ArgumentError, "#{target_name} is not found in #{proj_name}" if not @target
|
12
14
|
end
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
16
|
+
def wc(header_only=false, source_only=false)
|
17
|
+
all = !(header_only || source_only) # default is all
|
18
|
+
count_source = lambda do
|
19
|
+
sources = []
|
20
|
+
for file in @target.source_build_phase.files_references
|
21
|
+
if file.last_known_file_type and file.last_known_file_type.include? "sourcecode"
|
22
|
+
sources.push("'#{file.real_path}'")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
file_params = sources.join(' ')
|
26
|
+
source_total = %x{wc -l #{file_params}}
|
27
|
+
return source_total.lines[-1].split.first.to_i
|
28
|
+
end
|
17
29
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
30
|
+
count_header = lambda do
|
31
|
+
headers = []
|
32
|
+
for file in @proj.files
|
33
|
+
if file.path.end_with? ".h"
|
34
|
+
headers.push("'#{file.real_path}'")
|
35
|
+
end
|
24
36
|
end
|
37
|
+
file_params = headers.join(' ')
|
38
|
+
header_total = %x{wc -l #{file_params}}
|
39
|
+
return header_total.lines[-1].split.first.to_i
|
25
40
|
end
|
26
|
-
|
27
|
-
source_total =
|
28
|
-
|
41
|
+
|
42
|
+
source_total = header_total = 0
|
43
|
+
source_total = count_source.call if all or source_only
|
44
|
+
header_total = count_header.call if all or header_only
|
45
|
+
source_total + header_total
|
29
46
|
end
|
30
47
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
48
|
+
def show(kind, fullpath=false)
|
49
|
+
if kind == 'resource'
|
50
|
+
files = @target.resources_build_phase.files_references
|
51
|
+
elsif kind == 'source'
|
52
|
+
files = @target.source_build_phase.files_references
|
53
|
+
end
|
54
|
+
|
55
|
+
if files
|
56
|
+
for file in files
|
57
|
+
if fullpath
|
58
|
+
puts file.real_path
|
59
|
+
else
|
60
|
+
puts file.path
|
61
|
+
end
|
36
62
|
end
|
37
63
|
end
|
38
|
-
|
39
|
-
header_total = %x{wc -l #{file_params}}
|
40
|
-
return header_total.lines[-1].split.first.to_i
|
64
|
+
return nil
|
41
65
|
end
|
42
|
-
|
43
|
-
source_total = header_total = 0
|
44
|
-
source_total = count_source.call if all or source_only
|
45
|
-
header_total = count_header.call if all or header_only
|
46
|
-
source_total + header_total
|
47
66
|
end
|
48
67
|
end
|
data/xcodeproj_utils.gemspec
CHANGED
@@ -8,8 +8,13 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = XcodeprojUtils::VERSION
|
9
9
|
spec.authors = ["Matsumoto Taichi"]
|
10
10
|
spec.email = ["taichino@gmail.com"]
|
11
|
-
spec.summary = %q{
|
12
|
-
spec.description = %q{
|
11
|
+
spec.summary = %q{Util commands for xcode project.}
|
12
|
+
spec.description = %q{
|
13
|
+
Util commands for xcode project. Following commands are supported for now.
|
14
|
+
|
15
|
+
- Count source lines of files in xcode project
|
16
|
+
- Show source / resource files in xcode project
|
17
|
+
}
|
13
18
|
spec.homepage = "https://github.com/taichino/xcodeproj_utils"
|
14
19
|
spec.license = "MIT"
|
15
20
|
|
@@ -20,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
20
25
|
|
21
26
|
spec.add_development_dependency "bundler", "~> 1.5"
|
22
27
|
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency "thor"
|
24
28
|
|
25
|
-
spec.add_runtime_dependency "
|
29
|
+
spec.add_runtime_dependency "thor", "~> 0.18"
|
30
|
+
spec.add_runtime_dependency "xcodeproj", "~> 0.14"
|
26
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xcodeproj_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matsumoto Taichi
|
@@ -42,31 +42,36 @@ dependencies:
|
|
42
42
|
name: thor
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :
|
47
|
+
version: '0.18'
|
48
|
+
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
54
|
+
version: '0.18'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: xcodeproj
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
61
|
+
version: '0.14'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
description:
|
68
|
+
version: '0.14'
|
69
|
+
description: |2
|
70
|
+
|
71
|
+
Util commands for xcode project. Following commands are supported for now.
|
72
|
+
|
73
|
+
- Count source lines of files in xcode project
|
74
|
+
- Show source / resource files in xcode project
|
70
75
|
email:
|
71
76
|
- taichino@gmail.com
|
72
77
|
executables:
|
@@ -105,5 +110,5 @@ rubyforge_project:
|
|
105
110
|
rubygems_version: 2.0.6
|
106
111
|
signing_key:
|
107
112
|
specification_version: 4
|
108
|
-
summary:
|
113
|
+
summary: Util commands for xcode project.
|
109
114
|
test_files: []
|