class Xcodeproj::Workspace
documents.
Provides support for generating, reading and serializing Xcode Workspace
def self.from_s(xml, workspace_path='')
-
(Workspace)- the generated workspace.
Parameters:
-
xml(String) --
def self.from_s(xml, workspace_path='') document = REXML::Document.new(xml) projpaths = document.get_elements("/Workspace/FileRef").map do |node| node.attribute("location").value.sub(/^group:/, '') end instance = new(projpaths) instance.load_schemes(workspace_path) instance end
def self.new_from_xcworkspace(path)
-
(Workspace)- the generated workspace.
Parameters:
-
path(String) --
def self.new_from_xcworkspace(path) begin from_s(File.read(File.join(path, 'contents.xcworkspacedata')), File.expand_path(File.dirname(path))) rescue Errno::ENOENT new end end
def <<(projpath)
-
(void)-
Parameters:
-
projpath(String) --
def <<(projpath) @projpaths << projpath load_schemes_from_project File.expand_path(projpath) end
def include?(projpath)
-
(Boolean)- whether the project is contained in the workspace.
Parameters:
-
projpath(String) --
def include?(projpath) @projpaths.include?(projpath) end
def initialize(*projpaths)
-
projpaths(Array) -- @see projpaths
def initialize(*projpaths) @projpaths = projpaths.flatten @schemes = {} end
def load_schemes workspace_dir_path
-
(void)-
Parameters:
-
workspace_dir_path(String) --
def load_schemes workspace_dir_path @projpaths.each do |projpath| project_full_path = File.expand_path(File.join(workspace_dir_path, projpath)) load_schemes_from_project project_full_path end end
def load_schemes_from_project project_full_path
-
(void)-
Parameters:
-
project_full_path(String) --
def load_schemes_from_project project_full_path schemes = Xcodeproj::Project.schemes project_full_path schemes.each do |scheme_name| @schemes[scheme_name] = project_full_path end end
def save_as(path)
-
(void)-
Parameters:
-
path(String) --
def save_as(path) FileUtils.mkdir_p(path) File.open(File.join(path, 'contents.xcworkspacedata'), 'w') do |out| out << to_s end end
def to_s
-
(String)- the XML representation of the workspace.
def to_s REXML::Document.new(TEMPLATE).tap do |document| @projpaths.each do |projpath| document.root << REXML::Element.new("FileRef").tap do |el| el.attributes['location'] = "group:#{projpath}" end end end.to_s end