xcodeproj 0.16.1 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e231a1ef01dd74e08eacdac936ea8b3cbac2c47c
4
- data.tar.gz: ccaf12bb232a52d3e8de39063e68f211ea868d40
3
+ metadata.gz: 58c9efc19e5ebe6d1e236953a4ba523bd76284aa
4
+ data.tar.gz: 265bccb8aef4feda776f3161a2b7144d04092199
5
5
  SHA512:
6
- metadata.gz: 709ac0aac0f7894e4b4b0dcbfdedaaf5ddf553d2d88417519c7aa77511b2148b9ec9511cca566ff8ad75bc122fa66126620ab3e058bb04bbbabf8fe50964ff02
7
- data.tar.gz: 39b8796d646dc3fdf864d3ec6418b39d8715a90f4d15c32fd0f74e6c094cc84757d1c8eba716722a2c47533643f6425b72e5321140b081386c39e67e75dadc82
6
+ metadata.gz: 2f600fece068a72b186a2e4fbe2a62a96129256cd7c4356d1fce4e945ac2150e5f646acaae768fc534d968b5426a440e5dd0b245aaa473bffa853fc3e1eaa154
7
+ data.tar.gz: 0d36f633574ac627ed5737ebd6f963c2918f68fbf1afbd26d4b20e9f4e2989326aa548add0c3fa1910b1bbdeb55f9b4dcdd8dab45d7eabc8a51aa5c09c155aff
@@ -1,6 +1,6 @@
1
1
  module Xcodeproj
2
2
  # The version of the xcodeproj gem.
3
3
  #
4
- VERSION = '0.16.1' unless defined? Xcodeproj::VERSION
4
+ VERSION = '0.17.0' unless defined? Xcodeproj::VERSION
5
5
  end
6
6
 
@@ -1,5 +1,6 @@
1
1
  require 'fileutils'
2
2
  require 'rexml/document'
3
+ require 'xcodeproj/workspace/file_reference'
3
4
 
4
5
  module Xcodeproj
5
6
 
@@ -9,15 +10,16 @@ module Xcodeproj
9
10
  class Workspace
10
11
 
11
12
  # @return [Array<String>] the paths of the projects contained in the
13
+ # @return [Array<FileReference>] the paths of the projects contained in the
12
14
  # workspace.
13
15
  #
14
- attr_reader :projpaths
16
+ attr_reader :file_references
15
17
  attr_reader :schemes
16
18
 
17
- # @param [Array] projpaths @see projpaths
19
+ # @param [Array] file_references @see file_references
18
20
  #
19
- def initialize(*projpaths)
20
- @projpaths = projpaths.flatten
21
+ def initialize(*file_references)
22
+ @file_references = file_references.flatten
21
23
  @schemes = {}
22
24
  end
23
25
 
@@ -50,10 +52,10 @@ module Xcodeproj
50
52
  #
51
53
  def self.from_s(xml, workspace_path='')
52
54
  document = REXML::Document.new(xml)
53
- projpaths = document.get_elements("/Workspace/FileRef").map do |node|
54
- node.attribute("location").value.sub(/^group:/, '')
55
+ file_references = document.get_elements("/Workspace/FileRef").map do |node|
56
+ FileReference.from_node(node)
55
57
  end
56
- instance = new(projpaths)
58
+ instance = new(file_references)
57
59
  instance.load_schemes(workspace_path)
58
60
  instance
59
61
  end
@@ -69,19 +71,20 @@ module Xcodeproj
69
71
  # @return [void]
70
72
  #
71
73
  def <<(projpath)
72
- @projpaths << projpath
74
+ @file_references << projpath
73
75
  load_schemes_from_project File.expand_path(projpath)
74
76
  end
75
77
 
76
- # Checks if the workspace contains the project with the given path.
78
+ # Checks if the workspace contains the project with the given file
79
+ # reference.
77
80
  #
78
- # @param [String] projpath
79
- # The path of the project to add.
81
+ # @param [FileReference] file_reference
82
+ # The file_reference to the project.
80
83
  #
81
84
  # @return [Boolean] whether the project is contained in the workspace.
82
85
  #
83
- def include?(projpath)
84
- @projpaths.include?(projpath)
86
+ def include?(file_reference)
87
+ @file_references.include?(file_reference)
85
88
  end
86
89
 
87
90
  # The template to generate a workspace XML representation.
@@ -92,10 +95,8 @@ module Xcodeproj
92
95
  #
93
96
  def to_s
94
97
  REXML::Document.new(TEMPLATE).tap do |document|
95
- @projpaths.each do |projpath|
96
- document.root << REXML::Element.new("FileRef").tap do |el|
97
- el.attributes['location'] = "group:#{projpath}"
98
- end
98
+ @file_references.each do |file_reference|
99
+ document.root << file_reference.to_node
99
100
  end
100
101
  end.to_s
101
102
  end
@@ -124,9 +125,9 @@ module Xcodeproj
124
125
  # @return [void]
125
126
  #
126
127
  def load_schemes workspace_dir_path
127
- @projpaths.each do |projpath|
128
- project_full_path = File.expand_path(File.join(workspace_dir_path, projpath))
129
- load_schemes_from_project project_full_path
128
+ @file_references.each do |file_reference|
129
+ project_full_path = file_reference.absolute_path(workspace_dir_path)
130
+ load_schemes_from_project(project_full_path)
130
131
  end
131
132
  end
132
133
 
@@ -0,0 +1,87 @@
1
+ module Xcodeproj
2
+ class Workspace
3
+ # Describes a file reference of a Workspace.
4
+ #
5
+ class FileReference
6
+ # @return [String] the path to the project
7
+ #
8
+ attr_reader :path
9
+
10
+ # @return [String] the type of reference to the project
11
+ #
12
+ # This can be of the following values:
13
+ # - absolute
14
+ # - group
15
+ # - container
16
+ # - developer (unsupported)
17
+ #
18
+ attr_reader :type
19
+
20
+ # @param [#to_s] path @see path
21
+ # @param [#to_s] type @see type
22
+ #
23
+ def initialize(path, type="group")
24
+ @path = path.to_s
25
+ @type = type.to_s
26
+ end
27
+
28
+ # @return [Bool] Wether a file reference is equal to another.
29
+ #
30
+ def ==(other)
31
+ path == other.path && type == other.type
32
+ end
33
+ alias_method :eql?, :==
34
+
35
+ # @return [Fixnum] A hash identical for equals objects.
36
+ #
37
+ def hash
38
+ [path, type].hash
39
+ end
40
+
41
+ # Returns a file reference given XML representation.
42
+ #
43
+ # @param [REXML::Element] xml_node
44
+ # the XML representation.
45
+ #
46
+ # @return [FileReference] The new file reference instance.
47
+ #
48
+ def self.from_node(xml_node)
49
+ type, path = xml_node.attribute('location').value.split(':', 2)
50
+ new(path, type)
51
+ end
52
+
53
+ # @return [REXML::Element] the XML representation of the file reference.
54
+ #
55
+ def to_node
56
+ REXML::Element.new("FileRef").tap do |element|
57
+ element.attributes['location'] = "#{type}:#{path}"
58
+ end
59
+ end
60
+
61
+ # Returns the absolute path of a file reference given the path of the
62
+ # directory containing workspace.
63
+ #
64
+ # @param [#to_s] workspace_dir_path
65
+ # The Path of the directory containing the workspace.
66
+ #
67
+ # @return [String] The absolute path to the project.
68
+ #
69
+ def absolute_path(workspace_dir_path)
70
+ workspace_dir_path = workspace_dir_path.to_s
71
+ case type
72
+ when 'group'
73
+ File.expand_path(File.join(workspace_dir_path, path))
74
+ when 'container'
75
+ File.expand_path(File.join(workspace_dir_path, path))
76
+ when 'absolute'
77
+ File.expand_path(path)
78
+ when 'developer'
79
+ raise "Developer workspace file reference type is not yet " \
80
+ "#{self}"
81
+ else
82
+ raise "Unsupported workspace file reference type #{type}"
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcodeproj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.1
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eloy Duran
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-15 00:00:00.000000000 Z
11
+ date: 2014-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -92,6 +92,7 @@ files:
92
92
  - lib/xcodeproj/scheme.rb
93
93
  - lib/xcodeproj/user_interface.rb
94
94
  - lib/xcodeproj/workspace.rb
95
+ - lib/xcodeproj/workspace/file_reference.rb
95
96
  - lib/xcodeproj/xcodebuild_helper.rb
96
97
  homepage: https://github.com/cocoapods/xcodeproj
97
98
  licenses: