Class: Xcodeproj::XCScheme::ExecutionAction

Inherits:
XMLElementWrapper show all
Defined in:
lib/xcodeproj/scheme/execution_action.rb

Overview

This class wraps the ExecutionAction node of a .xcscheme XML file

Instance Attribute Summary

Attributes inherited from XMLElementWrapper

#xml_element

Instance Method Summary collapse

Methods inherited from XMLElementWrapper

#to_s

Constructor Details

#initialize(node = nil, action_type = nil) ⇒ ExecutionAction

Returns a new instance of ExecutionAction.

Parameters:

  • node (REXML::Element) (defaults to: nil)

    The ‘ExecutionAction’ XML node that this object will wrap. If nil, will create an empty one

  • action_type (Symbol) (defaults to: nil)

    One of ‘EXECUTION_ACTION_TYPE.keys`



13
14
15
16
17
18
19
# File 'lib/xcodeproj/scheme/execution_action.rb', line 13

def initialize(node = nil, action_type = nil)
  create_xml_element_with_fallback(node, 'ExecutionAction') do
    type = action_type || node.action_type
    raise "[Xcodeproj] Invalid ActionType `#{type}`" unless Constants::EXECUTION_ACTION_TYPE.keys.include?(type)
    @xml_element.attributes['ActionType'] = Constants::EXECUTION_ACTION_TYPE[type]
  end
end

Instance Method Details

#action_contentShellScriptActionContent, SendEmailActionContent

Returns:

  • (ShellScriptActionContent)

    If action_type is ‘Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction’ returns the contents of the shell script to run pre/post action.

  • (SendEmailActionContent)

    If action_type is ‘Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.SendEmailAction’ returns the contents of the email to send pre/post action.



39
40
41
42
43
44
45
46
47
48
# File 'lib/xcodeproj/scheme/execution_action.rb', line 39

def action_content
  case action_type
  when Constants::EXECUTION_ACTION_TYPE[:shell_script]
    ShellScriptActionContent.new(@xml_element.elements['ActionContent'])
  when Constants::EXECUTION_ACTION_TYPE[:send_email]
    SendEmailActionContent.new(@xml_element.elements['ActionContent'])
  else
    raise "[Xcodeproj] Invalid ActionType `#{action_type}`"
  end
end

#action_content=(value) ⇒ Object

Parameters:



54
55
56
57
58
59
60
# File 'lib/xcodeproj/scheme/execution_action.rb', line 54

def action_content=(value)
  raise "[Xcodeproj] Invalid ActionContent `#{value.class}` for " \
    "ActionType `#{action_type}`" unless valid_action_content?(value)

  @xml_element.delete_element('ActionContent')
  @xml_element.add_element(value.xml_element)
end

#action_typeString

Returns The ActionType of this ExecutionAction. One of two values:

Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction, Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.SendEmailAction.

Returns:

  • (String)

    The ActionType of this ExecutionAction. One of two values:

    Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction, Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.SendEmailAction



27
28
29
# File 'lib/xcodeproj/scheme/execution_action.rb', line 27

def action_type
  @xml_element.attributes['ActionType']
end