pod-builder 1.9.4 → 2.0.0.beta.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +9 -0
  3. data/README.md +50 -13
  4. data/exe/pod_builder +39 -28
  5. data/lib/pod_builder/analyze.rb +32 -7
  6. data/lib/pod_builder/analyzer.rb +16 -0
  7. data/lib/pod_builder/command/build.rb +44 -174
  8. data/lib/pod_builder/command/build_all.rb +2 -2
  9. data/lib/pod_builder/command/clean.rb +34 -55
  10. data/lib/pod_builder/command/clear_lldbinit.rb +7 -3
  11. data/lib/pod_builder/command/deintegrate.rb +29 -7
  12. data/lib/pod_builder/command/generate_lfs.rb +3 -3
  13. data/lib/pod_builder/command/generate_podspec.rb +3 -2
  14. data/lib/pod_builder/command/info.rb +1 -1
  15. data/lib/pod_builder/command/init.rb +37 -14
  16. data/lib/pod_builder/command/install_sources.rb +21 -14
  17. data/lib/pod_builder/command/none.rb +2 -2
  18. data/lib/pod_builder/command/restore_all.rb +4 -4
  19. data/lib/pod_builder/command/switch.rb +137 -95
  20. data/lib/pod_builder/command/sync_podfile.rb +5 -3
  21. data/lib/pod_builder/command/update.rb +5 -6
  22. data/lib/pod_builder/command/update_lldbinit.rb +11 -9
  23. data/lib/pod_builder/configuration.rb +88 -13
  24. data/lib/pod_builder/core.rb +95 -14
  25. data/lib/pod_builder/info.rb +32 -98
  26. data/lib/pod_builder/install.rb +255 -195
  27. data/lib/pod_builder/licenses.rb +4 -4
  28. data/lib/pod_builder/podfile.rb +300 -73
  29. data/lib/pod_builder/podfile/post_actions.rb +9 -15
  30. data/lib/pod_builder/podfile_cp.rb +93 -0
  31. data/lib/pod_builder/podfile_item.rb +181 -82
  32. data/lib/pod_builder/podspec.rb +144 -135
  33. data/lib/pod_builder/rome/post_install.rb +240 -0
  34. data/lib/pod_builder/rome/pre_install.rb +6 -0
  35. data/lib/pod_builder/templates/build_podfile.template +3 -3
  36. data/lib/pod_builder/version.rb +1 -1
  37. data/pod-builder.gemspec +5 -5
  38. metadata +23 -76
  39. data/Example/Frameworks/PodBuilder.json +0 -32
  40. data/Example/PodBuilderExample.xcodeproj/project.pbxproj +0 -416
  41. data/Example/PodBuilderExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  42. data/Example/PodBuilderExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  43. data/Example/PodBuilderExample.xcodeproj/project.xcworkspace/xcuserdata/tomas.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  44. data/Example/PodBuilderExample.xcodeproj/xcuserdata/tomas.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  45. data/Example/PodBuilderExample.xcworkspace/contents.xcworkspacedata +0 -10
  46. data/Example/PodBuilderExample/AppDelegate.swift +0 -47
  47. data/Example/PodBuilderExample/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -98
  48. data/Example/PodBuilderExample/Assets.xcassets/Contents.json +0 -6
  49. data/Example/PodBuilderExample/Base.lproj/LaunchScreen.storyboard +0 -25
  50. data/Example/PodBuilderExample/Base.lproj/Main.storyboard +0 -24
  51. data/Example/PodBuilderExample/Info.plist +0 -45
  52. data/Example/PodBuilderExample/ViewController.swift +0 -25
  53. data/Example/Podfile +0 -8
  54. data/Example/Podfile.lock +0 -16
  55. data/Example/Pods/Alamofire/LICENSE +0 -19
  56. data/Example/Pods/Alamofire/README.md +0 -242
  57. data/Example/Pods/Alamofire/Source/AFError.swift +0 -460
  58. data/Example/Pods/Alamofire/Source/Alamofire.swift +0 -465
  59. data/Example/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift +0 -37
  60. data/Example/Pods/Alamofire/Source/MultipartFormData.swift +0 -580
  61. data/Example/Pods/Alamofire/Source/NetworkReachabilityManager.swift +0 -233
  62. data/Example/Pods/Alamofire/Source/Notifications.swift +0 -55
  63. data/Example/Pods/Alamofire/Source/ParameterEncoding.swift +0 -483
  64. data/Example/Pods/Alamofire/Source/Request.swift +0 -654
  65. data/Example/Pods/Alamofire/Source/Response.swift +0 -567
  66. data/Example/Pods/Alamofire/Source/ResponseSerialization.swift +0 -715
  67. data/Example/Pods/Alamofire/Source/Result.swift +0 -300
  68. data/Example/Pods/Alamofire/Source/ServerTrustPolicy.swift +0 -307
  69. data/Example/Pods/Alamofire/Source/SessionDelegate.swift +0 -725
  70. data/Example/Pods/Alamofire/Source/SessionManager.swift +0 -896
  71. data/Example/Pods/Alamofire/Source/TaskDelegate.swift +0 -466
  72. data/Example/Pods/Alamofire/Source/Timeline.swift +0 -136
  73. data/Example/Pods/Alamofire/Source/Validation.swift +0 -315
  74. data/Example/Pods/Manifest.lock +0 -16
  75. data/Example/Pods/Pods.xcodeproj/project.pbxproj +0 -673
  76. data/Example/Pods/Pods.xcodeproj/xcuserdata/tomas.xcuserdatad/xcschemes/Alamofire.xcscheme +0 -60
  77. data/Example/Pods/Pods.xcodeproj/xcuserdata/tomas.xcuserdatad/xcschemes/Pods-PodBuilderExample.xcscheme +0 -60
  78. data/Example/Pods/Pods.xcodeproj/xcuserdata/tomas.xcuserdatad/xcschemes/xcschememanagement.plist +0 -21
  79. data/Example/Pods/Target Support Files/Alamofire/Alamofire-dummy.m +0 -5
  80. data/Example/Pods/Target Support Files/Alamofire/Alamofire-prefix.pch +0 -12
  81. data/Example/Pods/Target Support Files/Alamofire/Alamofire-umbrella.h +0 -16
  82. data/Example/Pods/Target Support Files/Alamofire/Alamofire.modulemap +0 -6
  83. data/Example/Pods/Target Support Files/Alamofire/Alamofire.xcconfig +0 -9
  84. data/Example/Pods/Target Support Files/Alamofire/Info.plist +0 -26
  85. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Info.plist +0 -26
  86. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-acknowledgements.markdown +0 -26
  87. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-acknowledgements.plist +0 -58
  88. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-dummy.m +0 -5
  89. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-frameworks.sh +0 -153
  90. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-resources.sh +0 -118
  91. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-umbrella.h +0 -16
  92. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample.debug.xcconfig +0 -11
  93. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample.modulemap +0 -6
  94. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample.release.xcconfig +0 -11
  95. data/lib/pod_builder/cocoapods/specification.rb +0 -27
@@ -1,466 +0,0 @@
1
- //
2
- // TaskDelegate.swift
3
- //
4
- // Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)
5
- //
6
- // Permission is hereby granted, free of charge, to any person obtaining a copy
7
- // of this software and associated documentation files (the "Software"), to deal
8
- // in the Software without restriction, including without limitation the rights
9
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- // copies of the Software, and to permit persons to whom the Software is
11
- // furnished to do so, subject to the following conditions:
12
- //
13
- // The above copyright notice and this permission notice shall be included in
14
- // all copies or substantial portions of the Software.
15
- //
16
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- // THE SOFTWARE.
23
- //
24
-
25
- import Foundation
26
-
27
- /// The task delegate is responsible for handling all delegate callbacks for the underlying task as well as
28
- /// executing all operations attached to the serial operation queue upon task completion.
29
- open class TaskDelegate: NSObject {
30
-
31
- // MARK: Properties
32
-
33
- /// The serial operation queue used to execute all operations after the task completes.
34
- public let queue: OperationQueue
35
-
36
- /// The data returned by the server.
37
- public var data: Data? { return nil }
38
-
39
- /// The error generated throughout the lifecyle of the task.
40
- public var error: Error?
41
-
42
- var task: URLSessionTask? {
43
- set {
44
- taskLock.lock(); defer { taskLock.unlock() }
45
- _task = newValue
46
- }
47
- get {
48
- taskLock.lock(); defer { taskLock.unlock() }
49
- return _task
50
- }
51
- }
52
-
53
- var initialResponseTime: CFAbsoluteTime?
54
- var credential: URLCredential?
55
- var metrics: AnyObject? // URLSessionTaskMetrics
56
-
57
- private var _task: URLSessionTask? {
58
- didSet { reset() }
59
- }
60
-
61
- private let taskLock = NSLock()
62
-
63
- // MARK: Lifecycle
64
-
65
- init(task: URLSessionTask?) {
66
- _task = task
67
-
68
- self.queue = {
69
- let operationQueue = OperationQueue()
70
-
71
- operationQueue.maxConcurrentOperationCount = 1
72
- operationQueue.isSuspended = true
73
- operationQueue.qualityOfService = .utility
74
-
75
- return operationQueue
76
- }()
77
- }
78
-
79
- func reset() {
80
- error = nil
81
- initialResponseTime = nil
82
- }
83
-
84
- // MARK: URLSessionTaskDelegate
85
-
86
- var taskWillPerformHTTPRedirection: ((URLSession, URLSessionTask, HTTPURLResponse, URLRequest) -> URLRequest?)?
87
- var taskDidReceiveChallenge: ((URLSession, URLSessionTask, URLAuthenticationChallenge) -> (URLSession.AuthChallengeDisposition, URLCredential?))?
88
- var taskNeedNewBodyStream: ((URLSession, URLSessionTask) -> InputStream?)?
89
- var taskDidCompleteWithError: ((URLSession, URLSessionTask, Error?) -> Void)?
90
-
91
- @objc(URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:)
92
- func urlSession(
93
- _ session: URLSession,
94
- task: URLSessionTask,
95
- willPerformHTTPRedirection response: HTTPURLResponse,
96
- newRequest request: URLRequest,
97
- completionHandler: @escaping (URLRequest?) -> Void)
98
- {
99
- var redirectRequest: URLRequest? = request
100
-
101
- if let taskWillPerformHTTPRedirection = taskWillPerformHTTPRedirection {
102
- redirectRequest = taskWillPerformHTTPRedirection(session, task, response, request)
103
- }
104
-
105
- completionHandler(redirectRequest)
106
- }
107
-
108
- @objc(URLSession:task:didReceiveChallenge:completionHandler:)
109
- func urlSession(
110
- _ session: URLSession,
111
- task: URLSessionTask,
112
- didReceive challenge: URLAuthenticationChallenge,
113
- completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void)
114
- {
115
- var disposition: URLSession.AuthChallengeDisposition = .performDefaultHandling
116
- var credential: URLCredential?
117
-
118
- if let taskDidReceiveChallenge = taskDidReceiveChallenge {
119
- (disposition, credential) = taskDidReceiveChallenge(session, task, challenge)
120
- } else if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust {
121
- let host = challenge.protectionSpace.host
122
-
123
- if
124
- let serverTrustPolicy = session.serverTrustPolicyManager?.serverTrustPolicy(forHost: host),
125
- let serverTrust = challenge.protectionSpace.serverTrust
126
- {
127
- if serverTrustPolicy.evaluate(serverTrust, forHost: host) {
128
- disposition = .useCredential
129
- credential = URLCredential(trust: serverTrust)
130
- } else {
131
- disposition = .cancelAuthenticationChallenge
132
- }
133
- }
134
- } else {
135
- if challenge.previousFailureCount > 0 {
136
- disposition = .rejectProtectionSpace
137
- } else {
138
- credential = self.credential ?? session.configuration.urlCredentialStorage?.defaultCredential(for: challenge.protectionSpace)
139
-
140
- if credential != nil {
141
- disposition = .useCredential
142
- }
143
- }
144
- }
145
-
146
- completionHandler(disposition, credential)
147
- }
148
-
149
- @objc(URLSession:task:needNewBodyStream:)
150
- func urlSession(
151
- _ session: URLSession,
152
- task: URLSessionTask,
153
- needNewBodyStream completionHandler: @escaping (InputStream?) -> Void)
154
- {
155
- var bodyStream: InputStream?
156
-
157
- if let taskNeedNewBodyStream = taskNeedNewBodyStream {
158
- bodyStream = taskNeedNewBodyStream(session, task)
159
- }
160
-
161
- completionHandler(bodyStream)
162
- }
163
-
164
- @objc(URLSession:task:didCompleteWithError:)
165
- func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
166
- if let taskDidCompleteWithError = taskDidCompleteWithError {
167
- taskDidCompleteWithError(session, task, error)
168
- } else {
169
- if let error = error {
170
- if self.error == nil { self.error = error }
171
-
172
- if
173
- let downloadDelegate = self as? DownloadTaskDelegate,
174
- let resumeData = (error as NSError).userInfo[NSURLSessionDownloadTaskResumeData] as? Data
175
- {
176
- downloadDelegate.resumeData = resumeData
177
- }
178
- }
179
-
180
- queue.isSuspended = false
181
- }
182
- }
183
- }
184
-
185
- // MARK: -
186
-
187
- class DataTaskDelegate: TaskDelegate, URLSessionDataDelegate {
188
-
189
- // MARK: Properties
190
-
191
- var dataTask: URLSessionDataTask { return task as! URLSessionDataTask }
192
-
193
- override var data: Data? {
194
- if dataStream != nil {
195
- return nil
196
- } else {
197
- return mutableData
198
- }
199
- }
200
-
201
- var progress: Progress
202
- var progressHandler: (closure: Request.ProgressHandler, queue: DispatchQueue)?
203
-
204
- var dataStream: ((_ data: Data) -> Void)?
205
-
206
- private var totalBytesReceived: Int64 = 0
207
- private var mutableData: Data
208
-
209
- private var expectedContentLength: Int64?
210
-
211
- // MARK: Lifecycle
212
-
213
- override init(task: URLSessionTask?) {
214
- mutableData = Data()
215
- progress = Progress(totalUnitCount: 0)
216
-
217
- super.init(task: task)
218
- }
219
-
220
- override func reset() {
221
- super.reset()
222
-
223
- progress = Progress(totalUnitCount: 0)
224
- totalBytesReceived = 0
225
- mutableData = Data()
226
- expectedContentLength = nil
227
- }
228
-
229
- // MARK: URLSessionDataDelegate
230
-
231
- var dataTaskDidReceiveResponse: ((URLSession, URLSessionDataTask, URLResponse) -> URLSession.ResponseDisposition)?
232
- var dataTaskDidBecomeDownloadTask: ((URLSession, URLSessionDataTask, URLSessionDownloadTask) -> Void)?
233
- var dataTaskDidReceiveData: ((URLSession, URLSessionDataTask, Data) -> Void)?
234
- var dataTaskWillCacheResponse: ((URLSession, URLSessionDataTask, CachedURLResponse) -> CachedURLResponse?)?
235
-
236
- func urlSession(
237
- _ session: URLSession,
238
- dataTask: URLSessionDataTask,
239
- didReceive response: URLResponse,
240
- completionHandler: @escaping (URLSession.ResponseDisposition) -> Void)
241
- {
242
- var disposition: URLSession.ResponseDisposition = .allow
243
-
244
- expectedContentLength = response.expectedContentLength
245
-
246
- if let dataTaskDidReceiveResponse = dataTaskDidReceiveResponse {
247
- disposition = dataTaskDidReceiveResponse(session, dataTask, response)
248
- }
249
-
250
- completionHandler(disposition)
251
- }
252
-
253
- func urlSession(
254
- _ session: URLSession,
255
- dataTask: URLSessionDataTask,
256
- didBecome downloadTask: URLSessionDownloadTask)
257
- {
258
- dataTaskDidBecomeDownloadTask?(session, dataTask, downloadTask)
259
- }
260
-
261
- func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) {
262
- if initialResponseTime == nil { initialResponseTime = CFAbsoluteTimeGetCurrent() }
263
-
264
- if let dataTaskDidReceiveData = dataTaskDidReceiveData {
265
- dataTaskDidReceiveData(session, dataTask, data)
266
- } else {
267
- if let dataStream = dataStream {
268
- dataStream(data)
269
- } else {
270
- mutableData.append(data)
271
- }
272
-
273
- let bytesReceived = Int64(data.count)
274
- totalBytesReceived += bytesReceived
275
- let totalBytesExpected = dataTask.response?.expectedContentLength ?? NSURLSessionTransferSizeUnknown
276
-
277
- progress.totalUnitCount = totalBytesExpected
278
- progress.completedUnitCount = totalBytesReceived
279
-
280
- if let progressHandler = progressHandler {
281
- progressHandler.queue.async { progressHandler.closure(self.progress) }
282
- }
283
- }
284
- }
285
-
286
- func urlSession(
287
- _ session: URLSession,
288
- dataTask: URLSessionDataTask,
289
- willCacheResponse proposedResponse: CachedURLResponse,
290
- completionHandler: @escaping (CachedURLResponse?) -> Void)
291
- {
292
- var cachedResponse: CachedURLResponse? = proposedResponse
293
-
294
- if let dataTaskWillCacheResponse = dataTaskWillCacheResponse {
295
- cachedResponse = dataTaskWillCacheResponse(session, dataTask, proposedResponse)
296
- }
297
-
298
- completionHandler(cachedResponse)
299
- }
300
- }
301
-
302
- // MARK: -
303
-
304
- class DownloadTaskDelegate: TaskDelegate, URLSessionDownloadDelegate {
305
-
306
- // MARK: Properties
307
-
308
- var downloadTask: URLSessionDownloadTask { return task as! URLSessionDownloadTask }
309
-
310
- var progress: Progress
311
- var progressHandler: (closure: Request.ProgressHandler, queue: DispatchQueue)?
312
-
313
- var resumeData: Data?
314
- override var data: Data? { return resumeData }
315
-
316
- var destination: DownloadRequest.DownloadFileDestination?
317
-
318
- var temporaryURL: URL?
319
- var destinationURL: URL?
320
-
321
- var fileURL: URL? { return destination != nil ? destinationURL : temporaryURL }
322
-
323
- // MARK: Lifecycle
324
-
325
- override init(task: URLSessionTask?) {
326
- progress = Progress(totalUnitCount: 0)
327
- super.init(task: task)
328
- }
329
-
330
- override func reset() {
331
- super.reset()
332
-
333
- progress = Progress(totalUnitCount: 0)
334
- resumeData = nil
335
- }
336
-
337
- // MARK: URLSessionDownloadDelegate
338
-
339
- var downloadTaskDidFinishDownloadingToURL: ((URLSession, URLSessionDownloadTask, URL) -> URL)?
340
- var downloadTaskDidWriteData: ((URLSession, URLSessionDownloadTask, Int64, Int64, Int64) -> Void)?
341
- var downloadTaskDidResumeAtOffset: ((URLSession, URLSessionDownloadTask, Int64, Int64) -> Void)?
342
-
343
- func urlSession(
344
- _ session: URLSession,
345
- downloadTask: URLSessionDownloadTask,
346
- didFinishDownloadingTo location: URL)
347
- {
348
- temporaryURL = location
349
-
350
- guard
351
- let destination = destination,
352
- let response = downloadTask.response as? HTTPURLResponse
353
- else { return }
354
-
355
- let result = destination(location, response)
356
- let destinationURL = result.destinationURL
357
- let options = result.options
358
-
359
- self.destinationURL = destinationURL
360
-
361
- do {
362
- if options.contains(.removePreviousFile), FileManager.default.fileExists(atPath: destinationURL.path) {
363
- try FileManager.default.removeItem(at: destinationURL)
364
- }
365
-
366
- if options.contains(.createIntermediateDirectories) {
367
- let directory = destinationURL.deletingLastPathComponent()
368
- try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true)
369
- }
370
-
371
- try FileManager.default.moveItem(at: location, to: destinationURL)
372
- } catch {
373
- self.error = error
374
- }
375
- }
376
-
377
- func urlSession(
378
- _ session: URLSession,
379
- downloadTask: URLSessionDownloadTask,
380
- didWriteData bytesWritten: Int64,
381
- totalBytesWritten: Int64,
382
- totalBytesExpectedToWrite: Int64)
383
- {
384
- if initialResponseTime == nil { initialResponseTime = CFAbsoluteTimeGetCurrent() }
385
-
386
- if let downloadTaskDidWriteData = downloadTaskDidWriteData {
387
- downloadTaskDidWriteData(
388
- session,
389
- downloadTask,
390
- bytesWritten,
391
- totalBytesWritten,
392
- totalBytesExpectedToWrite
393
- )
394
- } else {
395
- progress.totalUnitCount = totalBytesExpectedToWrite
396
- progress.completedUnitCount = totalBytesWritten
397
-
398
- if let progressHandler = progressHandler {
399
- progressHandler.queue.async { progressHandler.closure(self.progress) }
400
- }
401
- }
402
- }
403
-
404
- func urlSession(
405
- _ session: URLSession,
406
- downloadTask: URLSessionDownloadTask,
407
- didResumeAtOffset fileOffset: Int64,
408
- expectedTotalBytes: Int64)
409
- {
410
- if let downloadTaskDidResumeAtOffset = downloadTaskDidResumeAtOffset {
411
- downloadTaskDidResumeAtOffset(session, downloadTask, fileOffset, expectedTotalBytes)
412
- } else {
413
- progress.totalUnitCount = expectedTotalBytes
414
- progress.completedUnitCount = fileOffset
415
- }
416
- }
417
- }
418
-
419
- // MARK: -
420
-
421
- class UploadTaskDelegate: DataTaskDelegate {
422
-
423
- // MARK: Properties
424
-
425
- var uploadTask: URLSessionUploadTask { return task as! URLSessionUploadTask }
426
-
427
- var uploadProgress: Progress
428
- var uploadProgressHandler: (closure: Request.ProgressHandler, queue: DispatchQueue)?
429
-
430
- // MARK: Lifecycle
431
-
432
- override init(task: URLSessionTask?) {
433
- uploadProgress = Progress(totalUnitCount: 0)
434
- super.init(task: task)
435
- }
436
-
437
- override func reset() {
438
- super.reset()
439
- uploadProgress = Progress(totalUnitCount: 0)
440
- }
441
-
442
- // MARK: URLSessionTaskDelegate
443
-
444
- var taskDidSendBodyData: ((URLSession, URLSessionTask, Int64, Int64, Int64) -> Void)?
445
-
446
- func URLSession(
447
- _ session: URLSession,
448
- task: URLSessionTask,
449
- didSendBodyData bytesSent: Int64,
450
- totalBytesSent: Int64,
451
- totalBytesExpectedToSend: Int64)
452
- {
453
- if initialResponseTime == nil { initialResponseTime = CFAbsoluteTimeGetCurrent() }
454
-
455
- if let taskDidSendBodyData = taskDidSendBodyData {
456
- taskDidSendBodyData(session, task, bytesSent, totalBytesSent, totalBytesExpectedToSend)
457
- } else {
458
- uploadProgress.totalUnitCount = totalBytesExpectedToSend
459
- uploadProgress.completedUnitCount = totalBytesSent
460
-
461
- if let uploadProgressHandler = uploadProgressHandler {
462
- uploadProgressHandler.queue.async { uploadProgressHandler.closure(self.uploadProgress) }
463
- }
464
- }
465
- }
466
- }