5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/xcodeproj_utils.rb', line 5
def self.wc(proj_name, target_name, =false, source_only=false)
proj = Xcodeproj::Project::open(proj_name)
for t in proj.targets
next if t.name != target_name
target = t
break
end
if not target
abort("#{target_name} is not found in #{proj_name}")
end
all = !( || source_only) count_source = lambda do
sources = []
for file in target.source_build_phase.files_references
if file.last_known_file_type and file.last_known_file_type.include? "sourcecode"
sources.push("'#{file.real_path}'")
end
end
file_params = sources.join(' ')
source_total = %x{wc -l #{file_params}}
return source_total.lines[-1].split.first.to_i
end
= lambda do
= []
for file in proj.files
if file.path.end_with? ".h"
.push("'#{file.real_path}'")
end
end
file_params = .join(' ')
= %x{wc -l #{file_params}}
return .lines[-1].split.first.to_i
end
source_total = = 0
source_total = count_source.call if all or source_only
= .call if all or
source_total +
end
|