zerg_xcode 0.3 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ v0.3.1. Tiny hack to allow importing Xcode 3.0 projects.
2
+
1
3
  v0.3. Implemented addtarget.
2
4
 
3
5
  v0.2.1. Implemented lstargets.
data/README.textile CHANGED
@@ -25,6 +25,9 @@ zerg-xcode help ls
25
25
  zerg-xcode ls ProjectName
26
26
  </pre>
27
27
 
28
+ You can learn all about importing projects in
29
+ "this blog post":http://blog.costan.us/2009/02/iphone-development-and-code-sharing.html
30
+
28
31
  h2. Developer Notes
29
32
 
30
33
  The rest of the file is useful if you're considering tweaking the code. Here are
@@ -219,8 +219,10 @@ END
219
219
 
220
220
  # Cross-references the objects in two object graphs that are to be merged.
221
221
  # Returns a Hash associating objects in both the source and the target object
222
- # graphs with the corresponding objects in the
223
- def cross_reference(source, target, mappings = {})
222
+ # graphs with the target objects that represent the same entities.
223
+ # Setting strict to true returns fewer matches, and should be used for
224
+ # entangling projects. Setting strict to false should work better for merges.
225
+ def cross_reference(source, target, strict = false, mappings = {})
224
226
  if source.class != target.class
225
227
  raise "Attempting to cross-reference different kinds of objects - " +
226
228
  "#{source.class} != #{target.class}"
@@ -237,29 +239,32 @@ END
237
239
  return mappings
238
240
  end
239
241
 
240
- self.send cross_op, source, target, mappings
242
+ self.send cross_op, source, target, strict, mappings
241
243
  end
242
244
 
243
- def cross_reference_objects(source, target, mappings)
244
- return mappings if mappings[source] || mappings[target]
245
- return mappings if source.xref_key != target.xref_key
245
+ def cross_reference_objects(source, target, strict, mappings)
246
+ return mappings if mappings[source] || mappings[target]
247
+
248
+ if strict
249
+ return mappings if source.xref_key != target.xref_key
250
+ end
246
251
 
247
252
  mappings[target] = target
248
253
  mappings[source] = target
249
- cross_reference source._attr_hash, target._attr_hash, mappings
254
+ cross_reference source._attr_hash, target._attr_hash, strict, mappings
250
255
  end
251
256
  private :cross_reference_objects
252
257
 
253
- def cross_reference_hashes(source, target, mappings)
258
+ def cross_reference_hashes(source, target, strict, mappings)
254
259
  source.each_key do |key|
255
260
  p [source.keys, key] if source[key].nil?
256
- cross_reference source[key], target[key], mappings if target[key]
261
+ cross_reference source[key], target[key], strict, mappings if target[key]
257
262
  end
258
263
  mappings
259
264
  end
260
265
  private :cross_reference_hashes
261
266
 
262
- def cross_reference_enumerables(source, target, mappings)
267
+ def cross_reference_enumerables(source, target, strict, mappings)
263
268
  source_keys = {}
264
269
  source.each do |value|
265
270
  next unless value.kind_of? ZergXcode::XcodeObject
@@ -268,7 +273,7 @@ END
268
273
  target.each do |value|
269
274
  next unless value.kind_of? ZergXcode::XcodeObject
270
275
  next unless source_value = source_keys[value.xref_key]
271
- cross_reference source_value, value, mappings
276
+ cross_reference source_value, value, strict, mappings
272
277
  end
273
278
  mappings
274
279
  end
@@ -25,14 +25,34 @@ class Plugins::ImportTest < Test::Unit::TestCase
25
25
  project = ZergXcode.load 'testdata/ZergSupport'
26
26
  assert_import_identical project
27
27
  end
28
+
29
+ def test_import_identical_30app
30
+ project = ZergXcode.load 'testdata/TestApp30'
31
+ assert_import_identical project
32
+ end
28
33
 
34
+ def test_import_identical_30lib
35
+ project = ZergXcode.load 'testdata/TestApp30'
36
+ assert_import_identical project
37
+ end
38
+
29
39
  def test_import_differents
30
40
  small = ZergXcode.load 'testdata/TestApp'
41
+ large = ZergXcode.load 'testdata/ZergSupport'
42
+ assert_import_differents small, large
43
+ end
44
+
45
+ def test_import_differents_30
46
+ small = ZergXcode.load 'testdata/TestApp30'
47
+ large = ZergXcode.load 'testdata/TestLib30'
48
+ assert_import_differents small, large
49
+ end
50
+
51
+ def assert_import_differents(small, large)
31
52
  small_file_set = Set.new(small.all_files.map { |file| file[:path] })
32
53
  small_target_set = Set.new(small['targets'].map { |t| t['name'] })
33
54
  small_target_filesets = target_filesets small
34
55
 
35
- large = ZergXcode.load 'testdata/ZergSupport'
36
56
  large_file_set = Set.new(large.all_files.map { |file| file[:path] })
37
57
  large_target_set = Set.new(large['targets'].map { |t| t['name'] })
38
58
  large_target_filesets = target_filesets large
@@ -108,6 +128,16 @@ class Plugins::ImportTest < Test::Unit::TestCase
108
128
  project = ZergXcode.load 'testdata/ZergSupport'
109
129
  assert_cross_reference_covers_project project
110
130
  end
131
+
132
+ def test_cross_reference_identical_30app
133
+ project = ZergXcode.load 'testdata/TestApp30'
134
+ assert_cross_reference_covers_project project
135
+ end
136
+
137
+ def test_cross_reference_identical_30lib
138
+ project = ZergXcode.load 'testdata/TestLib30'
139
+ assert_cross_reference_covers_project project
140
+ end
111
141
 
112
142
  def assert_cross_reference_covers_project(project)
113
143
  cloned_project = ZergXcode::XcodeObject.from project
@@ -120,7 +150,8 @@ class Plugins::ImportTest < Test::Unit::TestCase
120
150
  end
121
151
 
122
152
  objects.each do |object|
123
- assert map.include?(object), "Missed object #{object.xref_key.inspect}"
153
+ assert map.include?(object),
154
+ "Missed object #{object.xref_key.inspect}: #{object.inspect}"
124
155
 
125
156
  assert_equal object.xref_key, map[object].xref_key,
126
157
  "Merge keys for cross-referenced objects do not match"
data/zerg_xcode.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{zerg_xcode}
5
- s.version = "0.3"
5
+ s.version = "0.3.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Victor Costan"]
9
- s.date = %q{2009-02-28}
9
+ s.date = %q{2009-03-28}
10
10
  s.default_executable = %q{bin/zerg-xcode}
11
11
  s.description = %q{Automated modifications for Xcode project files}
12
12
  s.email = %q{victor@zergling.net}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zerg_xcode
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.3"
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Costan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-28 00:00:00 -05:00
12
+ date: 2009-03-28 00:00:00 -04:00
13
13
  default_executable: bin/zerg-xcode
14
14
  dependencies: []
15
15