iut 0.2.0 → 0.2.1

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.
@@ -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: iut [command] [subcommand] [options] [TEST_PROJECT_NAME]
16
+ Usage:
17
+ Makes a iUnitTest's empty project named TEST_PROJECT_NAME.
17
18
 
18
- Commands are:
19
- Nothing command, makes a empty project of iUnitTest.
20
- The project name is specified by TEST_PROJECT_NAME.
21
- arc Set a compile flag to use ARC. And scanned all files.
22
- If a class doesn't use ARC, set a compile flag
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
- ex)
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| }
@@ -17,34 +17,33 @@ module Iut
17
17
 
18
18
  super_name = "NSObject"
19
19
 
20
- Dir.chdir self.project_path do
21
- Dir.glob("**/#{class_name}\.[hm]") do |f|
22
- context = File.read f
23
- # remove comments
24
- context.gsub! /\/\/.*\n/, ""
25
- context.gsub! /\/\*.*\*\//m, ""
26
- # remove spaces
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
- case f[-2, 2]
30
- when /.h/i
31
- # get a name of super class
32
- a = context.scan(/@interface.*:\s(\S+)/)
33
- super_name = a.first.first if a.first
34
-
35
- case context
36
- when /@property\s*\(.*copy(\s*|\]|\))/,
37
- /@property\s*\(.*retain(\s*|\]|\))/
38
- return true
39
- end
40
- when /.m/i
41
- case context
42
- when /\s+dealloc(\s*|\])/, /\s+autorelease(\s*|\])/,
43
- /\s+dealloc(\s*|\])/, /\s+release(\s*|\])/
44
- return true
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
- FileUtils.cp files.sort.reverse.first, Dir.glob("**/project.pbxproj").first
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
@@ -1,4 +1,4 @@
1
1
  # -*- coding:UTF-8 -*-
2
2
  module Iut
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
@@ -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 TestArc < Test::Unit::TestCase
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
- files = Dir.glob("**/project.pbxproj.2*")
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.0
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