Sha256: 9708043e5f3faae02cfa7a4ea227dda9512cd412a3c65c25f1fea484fc09ff59

Contents?: true

Size: 1.77 KB

Versions: 5

Compression:

Stored size: 1.77 KB

Contents

module Xcodeproj
  class Project
    module Object
      class AbstractObject

        def basename
          name || path || Pathname(real_path).basename.to_s
        end

        def referring_groups
          referrers.select { |ref| ref.is_a?(Xcodeproj::Project::Object::PBXGroup) }
        end

        def work_pathname
          # Intuitively, we want the work pathname to correspond 1-1 with the
          # view in the project hierarchy. Xcode's collapsed display of
          # identically-named localized files causes some complications, leading
          # to the special cases here.
          if self.equal?(project.main_group)
            @work_pathname ||= project.work_root_pathname
          elsif parent.is_a?(Xcodeproj::Project::Object::PBXVariantGroup)
            # Localized object, naming is handled differently.
            @work_pathname ||= parent.work_pathname + "#{display_name}.lproj" + parent.display_name
          elsif is_a?(Xcodeproj::Project::Object::PBXVariantGroup)
            # Localized container, has no path of its own.
            @work_pathname ||= parent.work_pathname
          else
            @work_pathname ||= parent.work_pathname + display_name
          end
        end

        def ensure_internal_consistency(group)
          @removed_from_groups = []
          # Objects should only have one referring group -- this is an internal consistency issue if there is more than 1.
          # Just remove all referring groups but the one we're passed
          referring_groups.each do |rg|
            unless rg == group
              rg.remove_reference(self)
              @removed_from_groups << rg.hierarchy_path
            end
          end
        end

        def sync(group)
          raise NotImplementedError
        end

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
synx-0.2.1 lib/synx/xcodeproj_ext/project/object/abstract_object.rb
synx-0.2.0 lib/synx/xcodeproj_ext/project/object/abstract_object.rb
synx-0.1.1 lib/synx/xcodeproj_ext/project/object/abstract_object.rb
synx-0.1.0 lib/synx/xcodeproj_ext/project/object/abstract_object.rb
synx-0.0.61 lib/synx/xcodeproj_ext/project/object/abstract_object.rb