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.



52
53
54
55
56
57
58
59
60
# File 'lib/xcode/scheme.rb', line 52

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

#archive_configObject

Returns the value of attribute archive_config.



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

def archive_config
  @archive_config
end

#build_configObject

Returns the value of attribute build_config.



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

def build_config
  @build_config
end

#build_targetsObject (readonly)

Returns the value of attribute build_targets.



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

def build_targets
  @build_targets
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#parentObject (readonly)

Returns the value of attribute parent.



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

def parent
  @parent
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

#test_configObject

Returns the value of attribute test_config.



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

def test_config
  @test_config
end

#test_targetsObject (readonly)

Returns the value of attribute test_targets.



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

def test_targets
  @test_targets
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.



46
47
48
49
50
# File 'lib/xcode/scheme.rb', line 46

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.



18
19
20
# File 'lib/xcode/scheme.rb', line 18

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.



25
26
27
28
29
30
31
32
33
34
# File 'lib/xcode/scheme.rb', line 25

def self.find_in_workspace(workspace)
  schemes = find_in_path(workspace, workspace.path)

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

  schemes
end

Instance Method Details

#builderObject

Returns a builder for building this scheme.

Returns:

  • a builder for building this scheme



65
66
67
# File 'lib/xcode/scheme.rb', line 65

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

#testable?Boolean

Returns true if the scheme is testable, false otherwise.

Returns:

  • (Boolean)

    true if the scheme is testable, false otherwise



76
77
78
# File 'lib/xcode/scheme.rb', line 76

def testable?
  !@test_config.nil?
end

#to_sObject



69
70
71
# File 'lib/xcode/scheme.rb', line 69

def to_s
  "#{name} (Scheme) in #{parent}"
end