<commit_before>require 'colored'

module Pod
  class Installer
    autoload :TargetInstaller,       'cocoapods/installer/target_installer'
    autoload :UserProjectIntegrator, 'cocoapods/installer/user_project_integrator'

    include Config::Mixin

    attr_reader :resolver, :sandbox, :lockfile

    def initialize(resolver)
      @resolver = resolver
      @podfile = resolver.podfile
      @sandbox = resolver.sandbox
    end

    def project
      return @project if @project
      @project = Pod::Project.new
      @project.user_build_configurations = @podfile.user_build_configurations
      pods.each do |pod|
        # Add all source files to the project grouped by pod
        pod.relative_source_files_by_spec.each do |spec, paths|
          parent_group = pod.local? ? @project.local_pods : @project.pods
          group = @project.add_spec_to_group(pod.name, parent_group)
          paths.each do |path|
            group.files.new('path' => path.to_s)
          end
        end
      end
      # Add a group to hold all the target support files
      @project.main_group.groups.new('name' => 'Targets Support Files')
      @project
    end

    def target_installers
      @target_installers ||= @podfile.target_definitions.values.map do |definition|
        TargetInstaller.new(@podfile, project, definition) unless definition.empty?
      end.compact
    end

    # Install the Pods. If the resolver indicated that a Pod should be installed
    #   and it exits, it is removed an then reinstalled. In any case if the Pod
    #   doesn't exits it is installed.
    #
    # @return [void]
    #
    def install_dependencies!
      pods.each do |pod|
        name = pod.top_specification.name
        should_install = @resolver.should_install?(name)  || !pod.exists?

        unless config.silent?
          marker = config.verbose ? "\n-> ".green : ''
          if subspec_name = pod.top_specification.preferred_dependency
            name = "#{pod.top_specification.name}/#{subspec_name} (#{pod.top_specification.version})"
          else
            name = pod.to_s
          end
          puts marker << ( should_install ?  "Installing #{name}".green : "Using #{name}" )
        end

        if should_install
          unless pod.downloaded?
            pod.implode
            download_pod(pod)
          end
          # The docs need to be generated before cleaning because the
          # documentation is created for all the subspecs.
          generate_docs(pod)
          # Here we clean pod's that just have been downloaded or have been
          # pre-downloaded in AbstractExternalSource#specification_from_sandbox.
          pod.clean! if config.clean?
        end
      end
    end

    def download_pod(pod)
      downloader = Downloader.for_pod(pod)
      # Force the `bleeding edge' version if necessary.
      if pod.top_specification.version.head?
        if downloader.respond_to?(:download_head)<commit_msg>Handle pods in (case-insensitive) alphabetical order.<commit_after>require 'colored'

module Pod
  class Installer
    autoload :TargetInstaller,       'cocoapods/installer/target_installer'
    autoload :UserProjectIntegrator, 'cocoapods/installer/user_project_integrator'

    include Config::Mixin

    attr_reader :resolver, :sandbox, :lockfile

    def initialize(resolver)
      @resolver = resolver
      @podfile = resolver.podfile
      @sandbox = resolver.sandbox
    end

    def project
      return @project if @project
      @project = Pod::Project.new
      @project.user_build_configurations = @podfile.user_build_configurations
      pods.each do |pod|
        # Add all source files to the project grouped by pod
        pod.relative_source_files_by_spec.each do |spec, paths|
          parent_group = pod.local? ? @project.local_pods : @project.pods
          group = @project.add_spec_to_group(pod.name, parent_group)
          paths.each do |path|
            group.files.new('path' => path.to_s)
          end
        end
      end
      # Add a group to hold all the target support files
      @project.main_group.groups.new('name' => 'Targets Support Files')
      @project
    end

    def target_installers
      @target_installers ||= @podfile.target_definitions.values.map do |definition|
        TargetInstaller.new(@podfile, project, definition) unless definition.empty?
      end.compact
    end

    # Install the Pods. If the resolver indicated that a Pod should be installed
    #   and it exits, it is removed an then reinstalled. In any case if the Pod
    #   doesn't exits it is installed.
    #
    # @return [void]
    #
    def install_dependencies!
      pods.sort_by { |pod| pod.top_specification.name.downcase }.each do |pod|
        name = pod.top_specification.name
        should_install = @resolver.should_install?(name) || !pod.exists?

        unless config.silent?
          marker = config.verbose ? "\n-> ".green : ''
          if subspec_name = pod.top_specification.preferred_dependency
            name = "#{pod.top_specification.name}/#{subspec_name} (#{pod.top_specification.version})"
          else
            name = pod.to_s
          end
          puts marker << ( should_install ? "Installing #{name}".green : "Using #{name}" )
        end

        if should_install
          unless pod.downloaded?
            pod.implode
            download_pod(pod)
          end
          # The docs need to be generated before cleaning because the
          # documentation is created for all the subspecs.
          generate_docs(pod)
          # Here we clean pod's that just have been downloaded or have been
          # pre-downloaded in AbstractExternalSource#specification_from_sandbox.
          pod.clean! if config.clean?
        end
      end
    end

    def download_pod(pod)
      downloader = Downloader.for_pod(pod)
      # Force the `bleeding edge' version if necessary.
      if pod.top_specification.version.head?
        if downloader.respond_to?(:download_head)
{'fraction_non_alphanumeric': 0.08297089327534292, 'fraction_numerical': 0.0, 'mean_word_length': 2.4520785219399537, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5907604', 'n_tokens_mistral': 1750, 'n_tokens_neox': 1700, 'n_words': 463}