Module: Xcode::ProjectReference

Defined in:
lib/xcode/project_reference.rb

Instance Method Summary collapse

Instance Method Details

#group(name, options = {}, &block) ⇒ Group

Note:

this will attempt to find the paths specified, if it fails to find them it will create one and then continue traversing.

Note:

this path functionality current is only exercised from the project level all groups will treat the path division ‘/` as simply a character.

Returns the group specified. If any part of the group does not exist along the path the group is created. Also paths can be specified to make the traversing of the groups easier.

Examples:

Traverse a path through the various sub-groups.


project.group('Vendor/MyCode/Support Files')
# is equivalent to ...
project.group('Vendor').first.group('MyCode').first.group('Supporting Files')

Parameters:

  • name (String)

    the group name to find/create

Returns:

  • (Group)

    the group with the specified name.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/xcode/project_reference.rb', line 26

def group(name,options = {},&block)
  # By default create missing groups along the way
  options = { :create => true }.merge(options)
  
  current_group = main_group
  
  # @todo consider this traversing and find/create as a normal procedure when
  #   traversing the project.
  
  name.split("/").each do |path_component|
    found_group = current_group.group(path_component).first
    
    if options[:create] and found_group.nil?
      found_group = current_group.create_group(path_component)
    end
    
    current_group = found_group
    
    break unless current_group
  end
  
  current_group.instance_eval(&block) if block_given? and current_group
  
  current_group
end