Class: Pod::Installer

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-multithread-installpod.rb,
lib/cocoapods-multithread-installpod.rb

Instance Method Summary collapse

Instance Method Details

#install_pod_sourcesObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/cocoapods-multithread-installpod.rb', line 7

def install_pod_sources
  @installed_specs = []
  pods_to_install = sandbox_state.added | sandbox_state.changed
  title_options = { :verbose_prefix => '-> '.green }

  work_q = Queue.new
  root_specs.sort_by(&:name).each{|spec| work_q.push spec }
  workers = (0...20).map do
    Thread.new do
      begin
        while spec = work_q.pop(true)
          if pods_to_install.include?(spec.name)
            if sandbox_state.changed.include?(spec.name) && sandbox.manifest
              previous = sandbox.manifest.version(spec.name)
              title = "Installing #{spec.name} #{spec.version} (was #{previous})"
            else
              title = "Installing #{spec}"
            end
            UI.titled_section(title.green, title_options) do
              install_source_of_pod(spec.name)
              #UI.titled_section("Installed #{spec}", title_options)
            end
          else
            UI.titled_section("Using #{spec}", title_options) do
              create_pod_installer(spec.name)
              #UI.titled_section("Installed #{spec}", title_options)
            end
          end
        end
      rescue ThreadError
      end
    end
  end
  UI.titled_section("Installing... Please Wait...", title_options)
  workers.map(&:join)
end