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_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 |
# 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:(.+)$/) project_path = "#{workspace_root}/#{matcher[1]}" @projects << Xcode::Project.new(project_path) 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
66 67 68 69 70 71 |
# File 'lib/xcode/workspace.rb', line 66 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.
59 60 61 62 63 64 |
# File 'lib/xcode/workspace.rb', line 59 def project(name) project = @projects.select {|c| c.name == name.to_s}.first raise "No such project #{name}, 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.
43 44 45 46 47 48 |
# File 'lib/xcode/workspace.rb', line 43 def scheme(name) scheme = schemes.select {|t| t.name == name.to_s}.first raise "No such scheme #{name}, available schemes are #{schemes.map {|t| t.name}.join(', ')}" if scheme.nil? yield scheme if block_given? scheme end |
#schemes ⇒ Array<Xcode::Scheme>
Returns available schemes for the workspace.
28 29 30 31 32 |
# File 'lib/xcode/workspace.rb', line 28 def schemes return @schemes unless @schemes.nil? @schemes = Xcode::Scheme.find_in_workspace(self) @schemes 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
73 74 75 |
# File 'lib/xcode/workspace.rb', line 73 def workspace_root File.dirname(@path) end |