Class: DownloadCommand
- Inherits:
-
Object
- Object
- DownloadCommand
- Defined in:
- lib/commands/download_command.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args) ⇒ DownloadCommand
constructor
A new instance of DownloadCommand.
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ DownloadCommand
Returns a new instance of DownloadCommand.
18 19 20 21 22 23 |
# File 'lib/commands/download_command.rb', line 18 def initialize(args) @config = args[:config] @networking = args[:networking] @api = args[:api] @platforms = args[:platforms] end |
Class Method Details
.new_with_defaults(options) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/commands/download_command.rb', line 4 def self.new_with_defaults() shell = ShellWrapper.new config = Configuration.new(shell) networking = Networking.new(config, [:is_retry_enabled]) api = API.new(shell, config, networking, ) DownloadCommand.new( config: config, networking: networking, api: api, platforms: [:platforms], ) end |
Instance Method Details
#run ⇒ Object
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 |
# File 'lib/commands/download_command.rb', line 25 def run @config.ensure_shell_commands @api.verify_server_version pool = Concurrent::FixedThreadPool.new(THREAD_POOL_SIZE) @mutex = Mutex.new @number_of_downloaded_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 download(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 "Downloaded and extracted #{@number_of_downloaded_archives} archives " + "(#{format_file_size(@total_archive_size)}), " + "skipped #{@number_of_skipped_archives} archives." end end |