iut 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/iut.gemspec +1 -1
- data/lib/iut.rb +15 -12
- data/lib/iut/arc.rb +43 -26
- data/lib/iut/version.rb +1 -1
- data/test/test_arc.rb +7 -0
- data/test/test_arc_change_settings.rb +11 -4
- metadata +2 -2
data/iut.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.authors = ["Katsuyoshi Ito"]
|
9
9
|
s.email = ["kito@itosoft.com"]
|
10
10
|
s.homepage = "https://github.com/katsuyoshi/iunittest"
|
11
|
-
s.summary = %q{It generates a iUnitTest test project for Xcode 4.x.}
|
11
|
+
s.summary = %q{It generates a iUnitTest test project for Xcode 4.x. Or set ARC compile flags. }
|
12
12
|
s.description = %q{After Xcode 4 released, the format of template project was changed. The aim of this command is to make a iUnitTest test project easily. }
|
13
13
|
|
14
14
|
s.rubyforge_project = "iut"
|
data/lib/iut.rb
CHANGED
@@ -13,21 +13,24 @@ opt = OptionParser.new
|
|
13
13
|
opt.on('-p', '--project PROJECT', 'Set project path PROJECT.') {|v| v }
|
14
14
|
|
15
15
|
opt.banner = <<EOF
|
16
|
-
Usage:
|
16
|
+
Usage:
|
17
|
+
Makes a iUnitTest's empty project named TEST_PROJECT_NAME.
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
-fno-objc-arc to the class.
|
24
|
-
arc revert Revert a previous arc command
|
19
|
+
iut TEST_PROJECT_NAME
|
20
|
+
|
21
|
+
Set the compile option Automatic Refarence counting to YES.
|
22
|
+
And scanned all files.
|
23
|
+
If a class doesn't use ARC, set a compile flag -fno-objc-arc to the class.
|
25
24
|
|
26
|
-
|
27
|
-
$ iut TestProject It makes iUnitTest's empty project TestProject.
|
28
|
-
$ iut arc Set a compile flag to use ARC.
|
29
|
-
$ iut arc revert Revert a previous arc command.
|
25
|
+
iut arc [subcommand] [options]
|
30
26
|
|
27
|
+
subcommands are:
|
28
|
+
Nothing subcommand, set compile flags of ARC.
|
29
|
+
It makes backup file.
|
30
|
+
revert Revert a project from previous arc command's backup.
|
31
|
+
clean Remove all backup files.
|
32
|
+
|
33
|
+
options are:
|
31
34
|
EOF
|
32
35
|
|
33
36
|
#opt.on('-h', '--help', 'show this help message and exit') {|v| }
|
data/lib/iut/arc.rb
CHANGED
@@ -17,34 +17,33 @@ module Iut
|
|
17
17
|
|
18
18
|
super_name = "NSObject"
|
19
19
|
|
20
|
-
Dir.
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
context.gsub! /\s+/, " "
|
20
|
+
Dir.glob("**/#{class_name}\.[hm]") do |f|
|
21
|
+
context = File.read f
|
22
|
+
# remove comments
|
23
|
+
context.gsub! /\/\/.*\n/, ""
|
24
|
+
context.gsub! /\/\*.*\*\//m, ""
|
25
|
+
# remove spaces
|
26
|
+
context.gsub! /\s+/, " "
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
28
|
+
case f[-2, 2]
|
29
|
+
when /.h/i
|
30
|
+
# get a name of super class
|
31
|
+
a = context.scan(/@interface.*:\s(\S+)/)
|
32
|
+
super_name = a.first.first if a.first
|
33
|
+
|
34
|
+
case context
|
35
|
+
when /@property\s*\(.*copy(\s*|\]|\))/,
|
36
|
+
/@property\s*\(.*retain(\s*|\]|\))/
|
37
|
+
return true
|
38
|
+
end
|
39
|
+
when /.m/i
|
40
|
+
case context
|
41
|
+
when /\s+dealloc(\s*|\])/, /\s+autorelease(\s*|\])/,
|
42
|
+
/\s+dealloc(\s*|\])/, /\s+release(\s*|\])/
|
43
|
+
return true
|
46
44
|
end
|
47
45
|
end
|
46
|
+
|
48
47
|
end
|
49
48
|
nonarc? super_name
|
50
49
|
end
|
@@ -98,7 +97,23 @@ module Iut
|
|
98
97
|
files << f if /project.pbxproj.\d{8}\-\d{6}/ =~ f
|
99
98
|
end
|
100
99
|
unless files.size == 0
|
101
|
-
|
100
|
+
f = files.sort.reverse.first
|
101
|
+
FileUtils.cp f, Dir.glob("**/project.pbxproj").first
|
102
|
+
FileUtils.rm f
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def clean
|
108
|
+
Dir.chdir self.project_path do
|
109
|
+
files = []
|
110
|
+
Dir.glob("**/project.pbxproj.*") do |f|
|
111
|
+
files << f if /project.pbxproj.\d{8}\-\d{6}/ =~ f
|
112
|
+
end
|
113
|
+
unless files.size == 0
|
114
|
+
files.each do |f|
|
115
|
+
FileUtils.rm f
|
116
|
+
end
|
102
117
|
end
|
103
118
|
end
|
104
119
|
end
|
@@ -115,6 +130,8 @@ module Iut
|
|
115
130
|
case ARGV[1]
|
116
131
|
when /revert/
|
117
132
|
arc.revert
|
133
|
+
when /clean/
|
134
|
+
arc.clean
|
118
135
|
else
|
119
136
|
arc.change_project_settings
|
120
137
|
end
|
data/lib/iut/version.rb
CHANGED
data/test/test_arc.rb
CHANGED
@@ -14,6 +14,13 @@ class TestArc < Test::Unit::TestCase
|
|
14
14
|
project_path = File.join(File.expand_path(File.dirname(__FILE__)), "files", "IUTTest")
|
15
15
|
@arc = Iut::Arc.new
|
16
16
|
@arc.project_path = project_path
|
17
|
+
|
18
|
+
@pwd = File.expand_path(Dir.pwd)
|
19
|
+
Dir.chdir @arc.project_path
|
20
|
+
end
|
21
|
+
|
22
|
+
def teardown
|
23
|
+
Dir.chdir @pwd
|
17
24
|
end
|
18
25
|
|
19
26
|
|
@@ -8,13 +8,12 @@ $:.unshift(iut_path) unless
|
|
8
8
|
require "arc"
|
9
9
|
|
10
10
|
|
11
|
-
class
|
11
|
+
class TestArcChangeSettings < Test::Unit::TestCase
|
12
12
|
|
13
13
|
def setup
|
14
14
|
project_path = File.join(File.expand_path(File.dirname(__FILE__)), "files", "IUTTest")
|
15
15
|
@arc = Iut::Arc.new
|
16
16
|
@arc.project_path = project_path
|
17
|
-
#p project_path
|
18
17
|
end
|
19
18
|
|
20
19
|
def teardown
|
@@ -57,8 +56,7 @@ class TestArc < Test::Unit::TestCase
|
|
57
56
|
def test_arc_make_backup
|
58
57
|
@arc.change_project_settings
|
59
58
|
Dir.chdir @arc.project_path do
|
60
|
-
|
61
|
-
assert_equal 1, files.size
|
59
|
+
assert_equal 1, Dir.glob("**/project.pbxproj.2*").size
|
62
60
|
end
|
63
61
|
end
|
64
62
|
|
@@ -67,6 +65,15 @@ class TestArc < Test::Unit::TestCase
|
|
67
65
|
@arc.revert
|
68
66
|
Dir.chdir @arc.project_path do
|
69
67
|
assert_equal File.read("IUTTest.xcodeproj/project.pbxproj.org"), File.read("IUTTest.xcodeproj/project.pbxproj")
|
68
|
+
assert_equal 0, Dir.glob("**/project.pbxproj.2*").size
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_clean
|
73
|
+
@arc.change_project_settings
|
74
|
+
@arc.clean
|
75
|
+
Dir.chdir @arc.project_path do
|
76
|
+
assert_equal 0, Dir.glob("**/project.pbxproj.2*").size
|
70
77
|
end
|
71
78
|
end
|
72
79
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iut
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -146,7 +146,7 @@ rubyforge_project: iut
|
|
146
146
|
rubygems_version: 1.8.10
|
147
147
|
signing_key:
|
148
148
|
specification_version: 3
|
149
|
-
summary: It generates a iUnitTest test project for Xcode 4.x.
|
149
|
+
summary: It generates a iUnitTest test project for Xcode 4.x. Or set ARC compile flags.
|
150
150
|
test_files:
|
151
151
|
- test/files/IUTTest/IUTTest.xcodeproj/project.pbxproj
|
152
152
|
- test/files/IUTTest/IUTTest.xcodeproj/project.pbxproj.expected
|