Class: Xcode::Workspace
- Inherits:
-
Object
- Object
- Xcode::Workspace
- Defined in:
- lib/xcode/workspace.rb,
lib/xcode/builder/scheme_builder.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#projects ⇒ Object
readonly
Returns the value of attribute projects.
Instance Method Summary collapse
- #describe ⇒ Object
-
#initialize(path) ⇒ Workspace
constructor
A new instance of Workspace.
-
#project(name) {|project| ... } ⇒ Project
Return the names project.
-
#scheme(name) {|scheme| ... } ⇒ Scheme
Return the scheme with the specified name.
-
#schemes ⇒ Array<Xcode::Scheme>
Available schemes for the workspace.
- #to_s ⇒ Object
- #to_xcodebuild_option ⇒ Object
- #workspace_root ⇒ Object
Constructor Details
#initialize(path) ⇒ Workspace
Returns a new instance of Workspace.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/xcode/workspace.rb', line 7 def initialize(path) path = "#{path}.xcworkspace" unless path=~/\.xcworkspace/ @name = File.basename(path.gsub(/\.xcworkspace/,'')) @projects = [] @schemes = nil @path = File. path doc = Nokogiri::XML(open("#{@path}/contents.xcworkspacedata")) doc.search("FileRef").each do |file| location = file["location"] if (matcher = location.match(/^group:(.+\.xcodeproj)$/i)) project_path = "#{workspace_root}/#{matcher[1]}" begin @projects << Xcode::Project.new(project_path) rescue => e puts "Skipping project file #{project_path} referened by #{self} as it failed to parse" end end end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/xcode/workspace.rb', line 6 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/xcode/workspace.rb', line 6 def path @path end |
#projects ⇒ Object (readonly)
Returns the value of attribute projects.
6 7 8 |
# File 'lib/xcode/workspace.rb', line 6 def projects @projects end |
Instance Method Details
#describe ⇒ Object
74 75 76 77 78 79 |
# File 'lib/xcode/workspace.rb', line 74 def describe puts "Workspace #{name} contains:" projects.each do |p| p.describe end end |
#project(name) {|project| ... } ⇒ Project
Note:
if two projects match names, the first matching scheme is returned.
Return the names project. Raises an error if no projects match the specified name.
63 64 65 66 67 68 |
# File 'lib/xcode/workspace.rb', line 63 def project(name) project = @projects.select {|c| c.name == name.to_s}.first raise "No such project #{name} in #{self}, available projects are #{@projects.map {|c| c.name}.join(', ')}" if project.nil? yield project if block_given? project end |
#scheme(name) {|scheme| ... } ⇒ Scheme
Note:
if two schemes match names, the first matching scheme is returned.
Return the scheme with the specified name. Raises an error if no schemes match the specified name.
47 48 49 50 51 52 |
# File 'lib/xcode/workspace.rb', line 47 def scheme(name) scheme = schemes.select {|t| t.name == name.to_s and t.parent == self}.first raise "No such scheme #{name} in #{self}, available schemes are #{schemes.map {|t| t.to_s}.join(', ')}" if scheme.nil? yield scheme if block_given? scheme end |
#schemes ⇒ Array<Xcode::Scheme>
Returns available schemes for the workspace.
32 33 34 35 36 |
# File 'lib/xcode/workspace.rb', line 32 def schemes return @schemes unless @schemes.nil? @schemes = Xcode::Scheme.find_in_workspace(self) @schemes end |
#to_s ⇒ Object
70 71 72 |
# File 'lib/xcode/workspace.rb', line 70 def to_s "#{name} (Workspace)" end |
#to_xcodebuild_option ⇒ Object
4 5 6 |
# File 'lib/xcode/builder/scheme_builder.rb', line 4 def to_xcodebuild_option "-workspace \"#{self.path}\"" end |
#workspace_root ⇒ Object
81 82 83 |
# File 'lib/xcode/workspace.rb', line 81 def workspace_root File.dirname(@path) end |