pbxplorer 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pbxplorer.rb +28 -24
  3. data/pbxplorer.gemspec +2 -2
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1ad5bd24111edaf2c3c324ecfe4772acd6f387e
4
- data.tar.gz: 5c640508e0d099855c7f017ab4304ddeb0ffa817
3
+ metadata.gz: f3e3f862284ccc9bc4118e8bf941411ba83f4506
4
+ data.tar.gz: e640e0417e43e687c7299fc85a340467df2a0e26
5
5
  SHA512:
6
- metadata.gz: 85f732fe2278610e18d0211517540c2ddc3257fef9ec2371e81a9354f31f74dd00c15501272bb49f52f9c09181e9961b9119ee40bfbe90ab562ea777efe5c5e5
7
- data.tar.gz: 1a5b74fe2add50a874e99ea97c79ebd0df6fa768b6988d543164b744f7a618fa6c4f89ee0c83dcb45afdecad08aa29d9fb074cb007be8b431d2f6033d5f0653a
6
+ metadata.gz: 77e9b960821c420de9ea6f3c1e076f4fad0d957783fab6ee2af082554fccbcdefd57080b4a27e6c491a1f66ca13f7d0533e487f47d0b1c28b128d8e297029961
7
+ data.tar.gz: e0040f5d1793f7c2a7c1cd6a02d195ce6ae52d5b56d106e404eba13592cc444d35643f9f875dadc3033a9b2fb1b10434c2ed3dc7c51995cb8e0ee23e15937ab2
@@ -1,19 +1,23 @@
1
1
  require 'json'
2
2
 
3
3
  class String
4
- alias to_plist to_json
4
+ alias to_pbx_plist to_json
5
+ end
6
+
7
+ class Fixnum
8
+ alias to_pbx_plist to_json
5
9
  end
6
10
 
7
11
  class Array
8
- def to_plist
9
- items = self.map { |item| "#{item.to_plist}" }
12
+ def to_pbx_plist
13
+ items = self.map { |item| "#{item.to_pbx_plist}" }
10
14
  "( #{items.join ","} )"
11
15
  end
12
16
  end
13
17
 
14
18
  class Hash
15
- def to_plist
16
- items = self.map { |key, val| "#{key.to_plist} = #{val.to_plist};\n" }
19
+ def to_pbx_plist
20
+ items = self.map { |key, val| "#{key.to_pbx_plist} = #{val.to_pbx_plist};\n" }
17
21
  "{ #{items.join} }"
18
22
  end
19
23
  end
@@ -21,7 +25,7 @@ end
21
25
  class PBXObject < Hash
22
26
  attr_accessor :project_file
23
27
  attr_reader :uuid
24
-
28
+
25
29
  def self.filter objs, attrs
26
30
  objs.select do |obj|
27
31
  attrs.select { |key, val| obj[key] == val }.length == attrs.length
@@ -33,13 +37,13 @@ class PBXObject < Hash
33
37
  objs = self.filter(objs, attrs) if attrs
34
38
  objs
35
39
  end
36
-
40
+
37
41
  def initialize hash={}, uuid=""
38
42
  24.times { uuid += "0123456789ABCDEF"[rand(16),1] } if uuid.empty?
39
-
43
+
40
44
  @project = nil
41
45
  @uuid = uuid
42
-
46
+
43
47
  self.merge! hash
44
48
  self["isa"] ||= self.class.to_s
45
49
  end
@@ -102,15 +106,15 @@ class PBXGroup < PBXObject
102
106
 
103
107
  children.flatten
104
108
  end
105
-
109
+
106
110
  def file_refs recursive=false
107
111
  PBXFileReference.objects_of_class self.children(recursive)
108
112
  end
109
-
113
+
110
114
  def subgroups recursive=false
111
115
  PBXGroup.objects_of_class self.children(recursive)
112
116
  end
113
-
117
+
114
118
  def variant_groups recursive=false
115
119
  PBXVariantGroup.objects_of_class self.children(recursive)
116
120
  end
@@ -162,7 +166,7 @@ class PBXProject < PBXObject
162
166
  def targets
163
167
  self.project_file.objects_with_uuids self["targets"]
164
168
  end
165
-
169
+
166
170
  def build_configuration_list
167
171
  self.project_file.object_with_uuid self["buildConfigurationList"]
168
172
  end
@@ -190,7 +194,7 @@ class XCProjectFile
190
194
  @path += "/project.pbxproj" if File.directory? @path
191
195
 
192
196
  @json = JSON.parse(`plutil -convert json -o - "#{@path}"`)
193
-
197
+
194
198
  objs = @json["objects"]
195
199
  @json["objects"] = {}
196
200
 
@@ -200,16 +204,16 @@ class XCProjectFile
200
204
  klass = Object.const_get hash["isa"]
201
205
  rescue
202
206
  end
203
-
207
+
204
208
  self.add_object klass.new(hash, uuid)
205
209
  end
206
210
  end
207
211
 
208
212
  def save path=nil
209
213
  path ||= @path
210
- File.open(path, "w") { |f| f.write @json.to_plist }
214
+ File.open(path, "w") { |f| f.write @json.to_pbx_plist }
211
215
  end
212
-
216
+
213
217
  def project
214
218
  self.object_with_uuid @json["rootObject"]
215
219
  end
@@ -231,31 +235,31 @@ class XCProjectFile
231
235
  objs = PBXObject.filter(objs, attrs) if attrs
232
236
  objs
233
237
  end
234
-
238
+
235
239
  def object_with_uuid uuid
236
240
  @json["objects"][uuid]
237
241
  end
238
-
242
+
239
243
  def new_object klass, attrs={}
240
244
  obj = klass.new attrs
241
245
  self.add_object obj
242
246
  obj
243
247
  end
244
-
248
+
245
249
  def add_object obj
246
250
  obj.project_file = self
247
251
  @json["objects"][obj.uuid] = obj
248
252
  end
249
-
253
+
250
254
  def remove_object obj
251
255
  obj.project_file = nil
252
256
  @json["objects"].delete obj.uuid
253
257
  end
254
-
258
+
255
259
  def remove_file_ref file_ref
256
260
  build_files = self.objects_of_class PBXBuildFile, { "fileRef" => file_ref.uuid }
257
261
  build_file_uuids = build_files.map { |obj| obj.uuid }
258
-
262
+
259
263
  build_files.each { |build_file| self.remove_object build_file }
260
264
  self.objects_of_class(PBXBuildPhase).each { |phase| phase["files"] -= build_file_uuids }
261
265
  self.objects_of_class(PBXGroup).each { |group| group["children"].delete file_ref }
@@ -266,7 +270,7 @@ class XCProjectFile
266
270
  puts "project = project_file.project"
267
271
  PBXProject
268
272
  end
269
-
273
+
270
274
  def inspect
271
275
  "{\n rootObject = #{@json['rootObject'].inspect}\n objects = < #{@json['objects'].length} objects >\n}"
272
276
  end
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "pbxplorer"
3
- s.version = "1.1.0"
4
- s.date = "2016-03-17"
3
+ s.version = "1.2.0"
4
+ s.date = "2017-07-11"
5
5
  s.summary = "Xcode project file editor"
6
6
  s.description = "pbxplorer is a set of Ruby classes for parsing, editing, and saving Xcode project (.pbxproj) files. It can also be used to explore the contents of a project using the interactive Ruby shell."
7
7
  s.authors = ["Mark Smith"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pbxplorer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-17 00:00:00.000000000 Z
11
+ date: 2017-07-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: pbxplorer is a set of Ruby classes for parsing, editing, and saving Xcode
14
14
  project (.pbxproj) files. It can also be used to explore the contents of a project
@@ -43,7 +43,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
43
43
  version: '0'
44
44
  requirements: []
45
45
  rubyforge_project:
46
- rubygems_version: 2.0.14
46
+ rubygems_version: 2.0.14.1
47
47
  signing_key:
48
48
  specification_version: 4
49
49
  summary: Xcode project file editor