xcodeproj 0.5.2 → 0.5.3

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.
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Xcodeproj
2
2
 
3
3
  [![Build Status](https://travis-ci.org/CocoaPods/Xcodeproj.png?branch=master)](https://travis-ci.org/CocoaPods/Xcodeproj)
4
+ [![Coverage Status](https://coveralls.io/repos/CocoaPods/Xcodeproj/badge.png?branch=master)](https://coveralls.io/r/CocoaPods/Xcodeproj)
4
5
 
5
6
  Xcodeproj lets you create and modify Xcode projects from [Ruby][ruby].
6
7
  Script boring management tasks or build Xcode-friendly libraries. Also includes
@@ -1,5 +1,5 @@
1
1
  module Xcodeproj
2
- VERSION = '0.5.2' unless defined? Xcodeproj::VERSION
2
+ VERSION = '0.5.3' unless defined? Xcodeproj::VERSION
3
3
 
4
4
  class PlainInformative < StandardError
5
5
  end
@@ -10,14 +10,40 @@ module Xcodeproj
10
10
  for one.}
11
11
  end
12
12
 
13
+ def self.options
14
+ [
15
+ ["--format [hash|tree_hash|raw]", "YAML output format, optional"],
16
+ ].concat(super)
17
+ end
18
+
13
19
  def initialize(argv)
14
20
  xcodeproj_path = argv.shift_argument
15
21
  @xcodeproj_path = File.expand_path(xcodeproj_path) if xcodeproj_path
22
+
23
+ if argv.option('--format')
24
+ @output_format = argv.shift_argument
25
+ end
26
+
16
27
  super unless argv.empty?
17
28
  end
18
29
 
19
30
  def run
20
31
  require 'yaml'
32
+
33
+ if @output_format
34
+ case @output_format.to_sym
35
+ when :hash
36
+ puts xcodeproj.to_hash.to_yaml
37
+ when :tree_hash
38
+ puts xcodeproj.to_tree_hash.to_yaml
39
+ when :raw
40
+ puts xcodeproj.to_yaml
41
+ else
42
+ raise Informative, "Unknowh format #{@output_format}!"
43
+ end
44
+ return
45
+ end
46
+
21
47
  pretty_print = xcodeproj.pretty_print
22
48
  sections = []
23
49
  pretty_print.each do |key, value|
@@ -186,12 +186,12 @@ module Xcodeproj
186
186
  end
187
187
  end
188
188
 
189
- # @return [Hash] The plist representation of the project.
189
+ # @return [Hash] The hash representation of the project.
190
190
  #
191
191
  def to_hash
192
192
  plist = {}
193
193
  objects_dictionary = {}
194
- objects.each { |obj| objects_dictionary[obj.uuid] = obj.to_plist }
194
+ objects.each { |obj| objects_dictionary[obj.uuid] = obj.to_hash }
195
195
  plist['objects'] = objects_dictionary
196
196
  plist['archiveVersion'] = archive_version.to_s
197
197
  plist['objectVersion'] = object_version.to_s
@@ -200,8 +200,6 @@ module Xcodeproj
200
200
  plist
201
201
  end
202
202
 
203
- alias :to_plist :to_hash
204
-
205
203
  # Converts the objects tree to a hash substituting the hash
206
204
  # of the referenced to their UUID reference. As a consequence the hash of
207
205
  # an object might appear multiple times and the information about their
@@ -251,7 +249,39 @@ module Xcodeproj
251
249
  def save_as(projpath)
252
250
  projpath = projpath.to_s
253
251
  FileUtils.mkdir_p(projpath)
254
- Xcodeproj.write_plist(to_plist, File.join(projpath, 'project.pbxproj'))
252
+ file = File.join(projpath, 'project.pbxproj')
253
+ Xcodeproj.write_plist(to_hash, file)
254
+ fix_encoding(file)
255
+ end
256
+
257
+ # Simple workaround to escape characters which are outside of ASCII
258
+ # character-encoding. Relies on the fact that there are no XML characters
259
+ # which would need to be escaped.
260
+ #
261
+ # @note This is necessary because Xcode (4.6 currently) uses the MacRoman
262
+ # encoding unless the `// !$*UTF8*$!` magic comment is present. It
263
+ # is not possible to serialize a plist using the NeXTSTEP format
264
+ # without access to the private classes of Xcode and that comment
265
+ # is not compatible with the XML format. For the complete
266
+ # discussion see CocoaPods/CocoaPods#926.
267
+ #
268
+ #
269
+ # @note Sadly this hack is not sufficient for supporting Emoji.
270
+ #
271
+ # @param [String, Pathname] The path of the file which needs to be fixed.
272
+ #
273
+ # @return [void]
274
+ #
275
+ def fix_encoding(file)
276
+ result = ''
277
+ File.read(file).unpack('U*').each do |codepoint|
278
+ if codepoint > 255
279
+ result << "&##{codepoint};"
280
+ else
281
+ result << codepoint.chr
282
+ end
283
+ end
284
+ File.open(file, 'w') { |write_file| write_file.write(result) }
255
285
  end
256
286
 
257
287
  #-------------------------------------------------------------------------#
@@ -245,7 +245,7 @@ module Xcodeproj
245
245
 
246
246
  unless object_plist.empty?
247
247
  raise "[!] Xcodeproj doesn't know about the following attributes " \
248
- "#{object_plist} for the '#{isa}' isa.\n" \
248
+ "#{object_plist.inspect} for the '#{isa}' isa.\n" \
249
249
  "Please file an issue: https://github.com/CocoaPods/Xcodeproj/issues/new"
250
250
  end
251
251
  end
@@ -286,11 +286,17 @@ module Xcodeproj
286
286
  "Please file an issue: https://github.com/CocoaPods/Xcodeproj/issues/new"
287
287
  end
288
288
 
289
+ # Returns a cascade representation of the object with UUIDs.
290
+ #
291
+ # @return [Hash] a hash representation of the project.
292
+ #
293
+ # @visibility public
294
+ #
289
295
  # @note the key for simple and to_one attributes usually appears only
290
296
  # if there is a value. To-many keys always appear with an empty
291
297
  # array.
292
298
  #
293
- def to_plist
299
+ def to_hash
294
300
  plist = {}
295
301
  plist['isa'] = isa
296
302
 
@@ -311,12 +317,11 @@ module Xcodeproj
311
317
 
312
318
  references_by_keys_attributes.each do |attrb|
313
319
  list = attrb.get_value(self)
314
- plist[attrb.plist_name] = list.map { |dictionary| dictionary.to_plist }
320
+ plist[attrb.plist_name] = list.map { |dictionary| dictionary.to_hash }
315
321
  end
316
322
 
317
323
  plist
318
324
  end
319
- alias :to_hash :to_plist
320
325
 
321
326
  # Returns a cascade representation of the object without UUIDs.
322
327
  #
@@ -378,7 +383,7 @@ module Xcodeproj
378
383
  # @!group Object methods
379
384
 
380
385
  def ==(other)
381
- other.is_a?(AbstractObject) && self.to_plist == other.to_plist
386
+ other.is_a?(AbstractObject) && self.to_hash == other.to_hash
382
387
  end
383
388
 
384
389
  def <=>(other)
@@ -108,7 +108,7 @@ module Xcodeproj
108
108
  #
109
109
  # @return [Hash<String => String>]
110
110
  #
111
- def to_plist
111
+ def to_hash
112
112
  result = {}
113
113
  each { |key, obj| result[key] = obj.uuid }
114
114
  result
metadata CHANGED
@@ -1,32 +1,36 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcodeproj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Eloy Duran
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-03-09 00:00:00.000000000 Z
12
+ date: 2013-04-03 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: activesupport
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
19
- version: 3.2.6
21
+ version: 3.2.13
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
26
- version: 3.2.6
29
+ version: 3.2.13
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: colored
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ~>
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ~>
39
44
  - !ruby/object:Gem::Version
@@ -84,26 +89,28 @@ files:
84
89
  homepage: https://github.com/cocoapods/xcodeproj
85
90
  licenses:
86
91
  - MIT
87
- metadata: {}
88
92
  post_install_message:
89
93
  rdoc_options: []
90
94
  require_paths:
91
95
  - ext
92
96
  - lib
93
97
  required_ruby_version: !ruby/object:Gem::Requirement
98
+ none: false
94
99
  requirements:
95
- - - '>='
100
+ - - ! '>='
96
101
  - !ruby/object:Gem::Version
97
102
  version: '0'
98
103
  required_rubygems_version: !ruby/object:Gem::Requirement
104
+ none: false
99
105
  requirements:
100
- - - '>='
106
+ - - ! '>='
101
107
  - !ruby/object:Gem::Version
102
108
  version: '0'
103
109
  requirements: []
104
110
  rubyforge_project:
105
- rubygems_version: 2.0.0
111
+ rubygems_version: 1.8.23
106
112
  signing_key:
107
113
  specification_version: 3
108
114
  summary: Create and modify Xcode projects from Ruby.
109
115
  test_files: []
116
+ has_rdoc:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: d27bcb437368807f65a764df534ed795799a8d8c
4
- data.tar.gz: 869df663efbe0382d011b29b76c896966cf62346
5
- SHA512:
6
- metadata.gz: bc75e39c69d54f041dfc67c90aa1815157770a80ab1de2e38f36eb7110381eb0602c9609254549e4f955b3fe311497c60dd2a4898d825eddece42adbb32dfd1c
7
- data.tar.gz: 8ac71b067eeb0eaa2132b489d299dd2b84052c65d0a1436f58d66168ad07844118a1a3481cd6f892004b8fe8f86aa9fb42939b881287ad64adbde27b733c6a1f