Class: Xcode::Scheme

Inherits:
Object
  • Object
show all
Defined in:
lib/xcode/scheme.rb

Overview

Schemes are an XML file that describe build, test, launch and profile actions For the purposes of Xcoder, we want to be able to build and test

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Scheme

Returns a new instance of Scheme.



47
48
49
50
51
52
53
54
55
# File 'lib/xcode/scheme.rb', line 47

def initialize(params={})
  @parent = params[:parent]
  @path = File.expand_path params[:path]
  @root = File.expand_path(File.join(params[:root],'..'))
  @name = File.basename(path).gsub(/\.xcscheme$/,'')
  doc = Nokogiri::XML(open(@path))      
  
  parse_build_actions(doc)
end

Instance Attribute Details

#build_configObject (readonly)

Returns the value of attribute build_config.



8
9
10
# File 'lib/xcode/scheme.rb', line 8

def build_config
  @build_config
end

#build_targetsObject (readonly)

Returns the value of attribute build_targets.



8
9
10
# File 'lib/xcode/scheme.rb', line 8

def build_targets
  @build_targets
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/xcode/scheme.rb', line 8

def name
  @name
end

#parentObject (readonly)

Returns the value of attribute parent.



8
9
10
# File 'lib/xcode/scheme.rb', line 8

def parent
  @parent
end

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/xcode/scheme.rb', line 8

def path
  @path
end

Class Method Details

.find_in_path(parent, path) ⇒ Array<Scheme>

Parse all the scheme files that can be found at the given path. Schemes can be defined as ‘shared` schemes and then `user` specific schemes. Parsing the schemes will load the shared ones and then the current acting user’s schemes.

Parameters:

  • project

    or workspace in which the scheme is contained

Returns:

  • (Array<Scheme>)

    the shared schemes and user specific schemes found within the project/workspace at the path defined for schemes.



41
42
43
44
45
# File 'lib/xcode/scheme.rb', line 41

def self.find_in_path(parent, path)
  all_schemes_paths(path).map do |scheme_path|
    Xcode::Scheme.new(parent: parent, root: path, path: scheme_path)
  end
end

.find_in_project(project) ⇒ Object

Parse all the schemes given the current project.



13
14
15
# File 'lib/xcode/scheme.rb', line 13

def self.find_in_project(project)
  find_in_path(project, project.path)
end

.find_in_workspace(workspace) ⇒ Object

Parse all the schemes given the current workspace.



20
21
22
23
24
25
26
27
28
29
# File 'lib/xcode/scheme.rb', line 20

def self.find_in_workspace(workspace)
  schemes = find_in_path(workspace, workspace.path)
  
  # Project level schemes
  workspace.projects.each do |project|
    schemes+=project.schemes
  end
  
  schemes
end

Instance Method Details

#builderObject

Returns a builder for building this scheme



58
59
60
# File 'lib/xcode/scheme.rb', line 58

def builder
  Xcode::Builder::SchemeBuilder.new(self)
end