xcodeproj_utils 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0c366badb7bfa7822537182db3ed58a79c9b262b
4
+ data.tar.gz: 88ba92593207b8b3ca362fa78ce0bc477d955387
5
+ SHA512:
6
+ metadata.gz: 677fe8bf453654e6c5a67d772dbbb26290ec0d5f12f755309e476d95fccb1ee3afcce8cb512ac8fffa887c24c970bed4c6b58d59d006648ebe0494a78d6027cb
7
+ data.tar.gz: 446b64ae5c01199650138d5fc06155a366381e5efcaf04c4608888ad056e8642fc915b1366d0472666507e6b9ca5beff9d3d9790ebc27f0d94929a6cd2c2e6f5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in xcodeproj_utils.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Matsumoto Taichi
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # XcodeprojUtils
2
+
3
+ Count source lines of files in xcode project.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'xcodeproj_utils'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install xcodeproj_utils
18
+
19
+ ## Usage
20
+
21
+ $ xcp_utils lines <PATH_TO_XCODE_PROJECT> <TARGET_NAME>
22
+ $ xcp_utils lines --header_only <PATH_TO_XCODE_PROJECT> <TARGET_NAME>
23
+ $ xcp_utils lines --source_only <PATH_TO_XCODE_PROJECT> <TARGET_NAME>
24
+
25
+ ## License
26
+
27
+ XcodeprojUtils is available under the MIT license. See the LICENSE file for more info.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/xcp_utils ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'thor'
4
+ require 'xcodeproj_utils'
5
+
6
+ class CLI < Thor
7
+ desc "Count source lines of files", "xcp_utils lines PROJECT_NAME TARGET_NAME"
8
+ option :header_only, :type => :boolean, :default => false, :desc => 'Count only header files'
9
+ option :source_only, :type => :boolean, :default => false, :desc => 'Count only source files'
10
+ def lines(proj_name, target_name)
11
+ header_only = options[:header_only]
12
+ source_only = options[:source_only]
13
+ if header_only or source_only
14
+ puts XcodeprojUtils.wc(proj_name, target_name, header_only=header_only, source_only=source_only)
15
+ else
16
+ puts XcodeprojUtils.wc(proj_name, target_name)
17
+ end
18
+ end
19
+ end
20
+
21
+ CLI.start(ARGV)
@@ -0,0 +1,3 @@
1
+ module XcodeprojUtils
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,48 @@
1
+ require "xcodeproj_utils/version"
2
+ require "Xcodeproj"
3
+
4
+ module XcodeprojUtils
5
+ def self.wc(proj_name, target_name, header_only=false, source_only=false)
6
+ proj = Xcodeproj::Project::open(proj_name)
7
+
8
+ for t in proj.targets
9
+ next if t.name != target_name
10
+ target = t
11
+ break
12
+ end
13
+
14
+ if not target
15
+ abort("#{target_name} is not found in #{proj_name}")
16
+ end
17
+
18
+ all = !(header_only || source_only) # default is all
19
+ count_source = lambda do
20
+ sources = []
21
+ for file in target.source_build_phase.files_references
22
+ if file.last_known_file_type and file.last_known_file_type.include? "sourcecode"
23
+ sources.push("'#{file.real_path}'")
24
+ end
25
+ end
26
+ file_params = sources.join(' ')
27
+ source_total = %x{wc -l #{file_params}}
28
+ return source_total.lines[-1].split.first.to_i
29
+ end
30
+
31
+ count_header = lambda do
32
+ headers = []
33
+ for file in proj.files
34
+ if file.path.end_with? ".h"
35
+ headers.push("'#{file.real_path}'")
36
+ end
37
+ end
38
+ file_params = headers.join(' ')
39
+ header_total = %x{wc -l #{file_params}}
40
+ return header_total.lines[-1].split.first.to_i
41
+ 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
+ end
48
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'xcodeproj_utils/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "xcodeproj_utils"
8
+ spec.version = XcodeprojUtils::VERSION
9
+ spec.authors = ["Matsumoto Taichi"]
10
+ spec.email = ["taichino@gmail.com"]
11
+ spec.summary = %q{Count source lines of files in xcode project.}
12
+ spec.description = %q{Count source lines of files in xcode project.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "thor"
24
+
25
+ spec.add_runtime_dependency "xcodeproj"
26
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: xcodeproj_utils
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Matsumoto Taichi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: xcodeproj
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Count source lines of files in xcode project.
70
+ email:
71
+ - taichino@gmail.com
72
+ executables:
73
+ - xcp_utils
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - bin/xcp_utils
82
+ - lib/xcodeproj_utils.rb
83
+ - lib/xcodeproj_utils/version.rb
84
+ - xcodeproj_utils.gemspec
85
+ homepage: ''
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.0.6
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: Count source lines of files in xcode project.
109
+ test_files: []