Class: CocoaPodsStats::TargetMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods_stats/target_mapper.rb

Instance Method Summary collapse

Instance Method Details

#pods_from_project(context, master_pods) ⇒ Object

Loop though all targets in the pod generate a collection of hashes



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/cocoapods_stats/target_mapper.rb', line 8

def pods_from_project(context, master_pods)
  context.umbrella_targets.flat_map do |target|
    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 } }

    # This will be an empty array for `integrate_targets: false` Podfiles
    user_targets(target).map do |user_target|
      # Send in a digested'd UUID anyway, a second layer
      # of misdirection can't hurt
      {
        :uuid => Digest::SHA256.hexdigest(user_target.uuid),
        :type => user_target.product_type,
        :pods => pods,
        :platform => user_target.platform_name,
      }
    end
  end
end