class Xcodeproj::XCScheme::EnvironmentVariables


LaunchAction or TestAction scheme group.
is just a container of EnvironmentVariable objects. It can either appear on a
This class wraps the EnvironmentVariables node of a .xcscheme XML file. This

def [](key)

Returns:
  • (EnvironmentVariable) - variable

Parameters:
  • key (String) --
def [](key)
  all_variables.find { |var| var.key == key }
end

def []=(key, value)

Returns:
  • (EnvironmentVariable) - variable

Parameters:
  • value (String) --
  • key (String) --
def []=(key, value)
  assign_variable(:key => key, :value => value)
  self[key]
end

def all_variables

Returns:
  • (Array) -
def all_variables
  @all_variables ||= @xml_element.get_elements(VARIABLE_NODE).map { |variable| EnvironmentVariable.new(variable) }
end

def assign_variable(variable)

Returns:
  • (Array) -

Parameters:
  • variable (EnvironmentVariable, Hash{Symbol => String,Bool}) --
def assign_variable(variable)
  env_var = variable.is_a?(EnvironmentVariable) ? variable : EnvironmentVariable.new(variable)
  all_variables.each { |existing_var| remove_variable(existing_var) if existing_var.key == env_var.key }
  @xml_element.add_element(env_var.xml_element)
  @all_variables << env_var
end

def initialize(node_or_variables = nil)

Parameters:
  • node_or_variables (nil, REXML::Element, Array, Array String,Bool}>) --
def initialize(node_or_variables = nil)
  create_xml_element_with_fallback(node_or_variables, VARIABLES_NODE) do
    @all_variables = []
    node_or_variables.each { |var| assign_variable(var) } unless node_or_variables.nil?
  end
end

def remove_variable(variable)

Returns:
  • (Array) -

Parameters:
  • variable (EnvironmentVariable, String) --
def remove_variable(variable)
  env_var = variable.is_a?(EnvironmentVariable) ? variable : all_variables.find { |var| var.key == variable }
  raise "Unexpected parameter type: #{env_var.class}" unless env_var.is_a?(EnvironmentVariable)
  @xml_element.delete_element(env_var.xml_element)
  @all_variables -= [env_var]
end

def to_a

Returns:
  • (Array String,Bool}>) -
def to_a
  all_variables.map(&:to_h)
end