Sha256: 42d0097f1339aa6849d0d027b26100d58966efdcf7f4180f6aa5b8ad5e828936

Contents?: true

Size: 1.3 KB

Versions: 5

Compression:

Stored size: 1.3 KB

Contents

require 'digest'
require 'xcodeproj'

module CocoaPodsStats
  class TargetMapper
    # Loop though all targets in the pod
    # generate a collection of hashes
    def pods_from_project(context, master_pods)
      context.umbrella_targets.flat_map do |target|
        next unless target.user_project_path

        # These UUIDs come from the Xcode project
        # http://danwright.info/blog/2010/10/xcode-pbxproject-files-3/

        project = Xcodeproj::Project.open(target.user_project_path)
        next unless project

        root_specs = target.specs.map(&:root).uniq

        # As it's hard to look up the source of a pod, we
        # can check if the pod exists in the master specs repo though

        pods = root_specs.
          select { |spec| master_pods.include?(spec.name) }.
          map { |spec| { :name => spec.name, :version => spec.version.to_s } }

        target.user_target_uuids.map do |uuid|
          project_target = project.objects_by_uuid[uuid]

          # Send in a digested'd UUID anyway, a second layer
          # of misdirection can't hurt
          {
            :uuid => Digest::SHA256.hexdigest(uuid),
            :type => project_target.product_type,
            :pods => pods,
            :platform => project_target.platform_name,
          }
        end
      end.compact
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cocoapods-stats-1.0.0.beta.1 lib/cocoapods_stats/target_mapper.rb
cocoapods-stats-0.6.2 lib/cocoapods_stats/target_mapper.rb
cocoapods-stats-0.6.1 lib/cocoapods_stats/target_mapper.rb
cocoapods-stats-0.6.0 lib/cocoapods_stats/target_mapper.rb
cocoapods-stats-0.5.3 lib/cocoapods_stats/target_mapper.rb