Permalink
Showing with 12 additions and 6 deletions.
  1. +2 −3 lib/xcodeproj/project/object.rb
  2. +10 −3 lib/xcodeproj/project/object/group.rb
@@ -362,9 +362,8 @@ def <=>(other)
end
def inspect
- s = "#<UUID: `#{uuid}', isa: `#{isa}'>"
- s << ", name: `#{name}'" if respond_to?(:name) && name
- s
+ name = " name=#{name}" if respond_to?(:name)
+ "<#{self.class}#{name} UUID=#{uuid}>"
end
end
end
@@ -174,14 +174,14 @@ def new_xcdatamodel_group(xcdatamodel_path)
end
# Traverses the children groups and finds the group with the given
- # path, optionally, creating any needed group.
+ # path, if exists.
#
# @param path (see #find_subpath)
#
# @note (see #find_subpath)
#
def [](path)
- find_subpath(path)
+ find_subpath(path, false)
end
# Removes children files and groups under this group.
@@ -211,13 +211,20 @@ def remove_children_recursively
# g.name #=> 'Frameworks'
#
# @return [PBXGroup] the group if found.
+ # @return [Nil] if the path could not be found and should create is false.
#
def find_subpath(path, should_create = false)
return self unless path
path = path.split('/') unless path.is_a?(Array)
child_name = path.shift
child = children.find{ |c| c.display_name == child_name }
- child = new_group(child_name) if child.nil? && should_create
+ if child.nil?
+ if should_create
+ child = new_group(child_name)
+ else
+ return nil
+ end
+ end
if path.empty?
child
else

0 comments on commit 10da95e

Please sign in to comment.