Class: UploadCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/commands/upload_command.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ UploadCommand

Returns a new instance of UploadCommand.



17
18
19
20
21
# File 'lib/commands/upload_command.rb', line 17

def initialize(args)
  @config = args[:config]
  @networking = args[:networking]
  @api = args[:api]
end

Class Method Details

.new_with_defaults(options) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/commands/upload_command.rb', line 4

def self.new_with_defaults(options)
  shell = ShellWrapper.new
  config = Configuration.new(shell)
  networking = Networking.new(config, options[:is_retry_enabled])
  api = API.new(shell, config, networking, options)

  UploadCommand.new(
    config: config,
    networking: networking,
    api: api,
  )
end

Instance Method Details

#runObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/commands/upload_command.rb', line 23

def run
  @config.ensure_shell_commands
  @api.verify_server_version
  @api.verify_build_dir_matches_cartfile_resolved

  pool = Concurrent::FixedThreadPool.new(THREAD_POOL_SIZE)

  $LOG.debug("Will upload frameworks: #{@config.all_framework_names}")

  @mutex = Mutex.new
  @number_of_uploaded_archives = 0
  @number_of_skipped_archives = 0
  @total_archive_size = 0
  errors = Concurrent::Array.new

  for carthage_dependency in @config.carthage_resolved_dependencies
    pool.post(carthage_dependency) do |carthage_dependency|
      begin
        upload(carthage_dependency)
      rescue => e
        errors << e
      end
    end
  end

  pool.shutdown
  pool.wait_for_termination

  if errors.count > 0
    raise MultipleErrorsError.new(errors)
  else
    puts "Uploaded #{@number_of_uploaded_archives} archives " +
           "(#{format_file_size(@total_archive_size)}), " +
           "skipped #{@number_of_skipped_archives}."
  end
end