pod-builder 1.9.2 → 2.0.0.beta.21

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 (91) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +9 -0
  3. data/Example/PodBuilder/.gitignore +6 -0
  4. data/Example/PodBuilder/.pod_builder/pod_builder +0 -0
  5. data/Example/{Frameworks → PodBuilder}/PodBuilder.json +10 -4
  6. data/Example/PodBuilder/Podfile +23 -0
  7. data/Example/PodBuilder/Podfile.restore +40 -0
  8. data/Example/PodBuilderExample.xcodeproj/project.pbxproj +3 -8
  9. data/Example/{PodBuilderExample.xcodeproj/xcuserdata/tomas.xcuserdatad/xcschemes/xcschememanagement.plist → PodBuilderExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist} +2 -8
  10. data/Example/PodBuilderExample/AppDelegate.swift +4 -0
  11. data/Example/Podfile +42 -1
  12. data/Example/Podfile.lock +426 -7
  13. data/Example/Pods-acknowledgements.md +210 -0
  14. data/Example/Pods-acknowledgements.plist +206 -0
  15. data/README.md +50 -13
  16. data/exe/pod_builder +39 -28
  17. data/lib/pod_builder/analyze.rb +32 -7
  18. data/lib/pod_builder/analyzer.rb +16 -0
  19. data/lib/pod_builder/command/build.rb +44 -161
  20. data/lib/pod_builder/command/build_all.rb +2 -2
  21. data/lib/pod_builder/command/clean.rb +34 -55
  22. data/lib/pod_builder/command/clear_lldbinit.rb +7 -3
  23. data/lib/pod_builder/command/deintegrate.rb +29 -7
  24. data/lib/pod_builder/command/generate_lfs.rb +3 -3
  25. data/lib/pod_builder/command/generate_podspec.rb +3 -2
  26. data/lib/pod_builder/command/info.rb +1 -1
  27. data/lib/pod_builder/command/init.rb +37 -14
  28. data/lib/pod_builder/command/install_sources.rb +21 -14
  29. data/lib/pod_builder/command/none.rb +2 -2
  30. data/lib/pod_builder/command/restore_all.rb +4 -4
  31. data/lib/pod_builder/command/switch.rb +137 -95
  32. data/lib/pod_builder/command/sync_podfile.rb +5 -3
  33. data/lib/pod_builder/command/update.rb +5 -6
  34. data/lib/pod_builder/command/update_lldbinit.rb +11 -9
  35. data/lib/pod_builder/configuration.rb +88 -13
  36. data/lib/pod_builder/core.rb +93 -12
  37. data/lib/pod_builder/info.rb +32 -98
  38. data/lib/pod_builder/install.rb +255 -195
  39. data/lib/pod_builder/licenses.rb +4 -4
  40. data/lib/pod_builder/podfile.rb +287 -73
  41. data/lib/pod_builder/podfile/post_actions.rb +9 -15
  42. data/lib/pod_builder/podfile_cp.rb +93 -0
  43. data/lib/pod_builder/podfile_item.rb +181 -82
  44. data/lib/pod_builder/podspec.rb +144 -135
  45. data/lib/pod_builder/rome/post_install.rb +240 -0
  46. data/lib/pod_builder/rome/pre_install.rb +6 -0
  47. data/lib/pod_builder/templates/build_podfile.template +3 -3
  48. data/lib/pod_builder/version.rb +1 -1
  49. data/pod-builder.gemspec +4 -4
  50. metadata +34 -65
  51. data/Example/Pods/Alamofire/LICENSE +0 -19
  52. data/Example/Pods/Alamofire/README.md +0 -242
  53. data/Example/Pods/Alamofire/Source/AFError.swift +0 -460
  54. data/Example/Pods/Alamofire/Source/Alamofire.swift +0 -465
  55. data/Example/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift +0 -37
  56. data/Example/Pods/Alamofire/Source/MultipartFormData.swift +0 -580
  57. data/Example/Pods/Alamofire/Source/NetworkReachabilityManager.swift +0 -233
  58. data/Example/Pods/Alamofire/Source/Notifications.swift +0 -55
  59. data/Example/Pods/Alamofire/Source/ParameterEncoding.swift +0 -483
  60. data/Example/Pods/Alamofire/Source/Request.swift +0 -654
  61. data/Example/Pods/Alamofire/Source/Response.swift +0 -567
  62. data/Example/Pods/Alamofire/Source/ResponseSerialization.swift +0 -715
  63. data/Example/Pods/Alamofire/Source/Result.swift +0 -300
  64. data/Example/Pods/Alamofire/Source/ServerTrustPolicy.swift +0 -307
  65. data/Example/Pods/Alamofire/Source/SessionDelegate.swift +0 -725
  66. data/Example/Pods/Alamofire/Source/SessionManager.swift +0 -896
  67. data/Example/Pods/Alamofire/Source/TaskDelegate.swift +0 -466
  68. data/Example/Pods/Alamofire/Source/Timeline.swift +0 -136
  69. data/Example/Pods/Alamofire/Source/Validation.swift +0 -315
  70. data/Example/Pods/Manifest.lock +0 -16
  71. data/Example/Pods/Pods.xcodeproj/project.pbxproj +0 -673
  72. data/Example/Pods/Pods.xcodeproj/xcuserdata/tomas.xcuserdatad/xcschemes/Alamofire.xcscheme +0 -60
  73. data/Example/Pods/Pods.xcodeproj/xcuserdata/tomas.xcuserdatad/xcschemes/Pods-PodBuilderExample.xcscheme +0 -60
  74. data/Example/Pods/Pods.xcodeproj/xcuserdata/tomas.xcuserdatad/xcschemes/xcschememanagement.plist +0 -21
  75. data/Example/Pods/Target Support Files/Alamofire/Alamofire-dummy.m +0 -5
  76. data/Example/Pods/Target Support Files/Alamofire/Alamofire-prefix.pch +0 -12
  77. data/Example/Pods/Target Support Files/Alamofire/Alamofire-umbrella.h +0 -16
  78. data/Example/Pods/Target Support Files/Alamofire/Alamofire.modulemap +0 -6
  79. data/Example/Pods/Target Support Files/Alamofire/Alamofire.xcconfig +0 -9
  80. data/Example/Pods/Target Support Files/Alamofire/Info.plist +0 -26
  81. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Info.plist +0 -26
  82. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-acknowledgements.markdown +0 -26
  83. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-acknowledgements.plist +0 -58
  84. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-dummy.m +0 -5
  85. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-frameworks.sh +0 -153
  86. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-resources.sh +0 -118
  87. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample-umbrella.h +0 -16
  88. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample.debug.xcconfig +0 -11
  89. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample.modulemap +0 -6
  90. data/Example/Pods/Target Support Files/Pods-PodBuilderExample/Pods-PodBuilderExample.release.xcconfig +0 -11
  91. data/lib/pod_builder/cocoapods/specification.rb +0 -27
@@ -1,136 +0,0 @@
1
- //
2
- // Timeline.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
- /// Responsible for computing the timing metrics for the complete lifecycle of a `Request`.
28
- public struct Timeline {
29
- /// The time the request was initialized.
30
- public let requestStartTime: CFAbsoluteTime
31
-
32
- /// The time the first bytes were received from or sent to the server.
33
- public let initialResponseTime: CFAbsoluteTime
34
-
35
- /// The time when the request was completed.
36
- public let requestCompletedTime: CFAbsoluteTime
37
-
38
- /// The time when the response serialization was completed.
39
- public let serializationCompletedTime: CFAbsoluteTime
40
-
41
- /// The time interval in seconds from the time the request started to the initial response from the server.
42
- public let latency: TimeInterval
43
-
44
- /// The time interval in seconds from the time the request started to the time the request completed.
45
- public let requestDuration: TimeInterval
46
-
47
- /// The time interval in seconds from the time the request completed to the time response serialization completed.
48
- public let serializationDuration: TimeInterval
49
-
50
- /// The time interval in seconds from the time the request started to the time response serialization completed.
51
- public let totalDuration: TimeInterval
52
-
53
- /// Creates a new `Timeline` instance with the specified request times.
54
- ///
55
- /// - parameter requestStartTime: The time the request was initialized. Defaults to `0.0`.
56
- /// - parameter initialResponseTime: The time the first bytes were received from or sent to the server.
57
- /// Defaults to `0.0`.
58
- /// - parameter requestCompletedTime: The time when the request was completed. Defaults to `0.0`.
59
- /// - parameter serializationCompletedTime: The time when the response serialization was completed. Defaults
60
- /// to `0.0`.
61
- ///
62
- /// - returns: The new `Timeline` instance.
63
- public init(
64
- requestStartTime: CFAbsoluteTime = 0.0,
65
- initialResponseTime: CFAbsoluteTime = 0.0,
66
- requestCompletedTime: CFAbsoluteTime = 0.0,
67
- serializationCompletedTime: CFAbsoluteTime = 0.0)
68
- {
69
- self.requestStartTime = requestStartTime
70
- self.initialResponseTime = initialResponseTime
71
- self.requestCompletedTime = requestCompletedTime
72
- self.serializationCompletedTime = serializationCompletedTime
73
-
74
- self.latency = initialResponseTime - requestStartTime
75
- self.requestDuration = requestCompletedTime - requestStartTime
76
- self.serializationDuration = serializationCompletedTime - requestCompletedTime
77
- self.totalDuration = serializationCompletedTime - requestStartTime
78
- }
79
- }
80
-
81
- // MARK: - CustomStringConvertible
82
-
83
- extension Timeline: CustomStringConvertible {
84
- /// The textual representation used when written to an output stream, which includes the latency, the request
85
- /// duration and the total duration.
86
- public var description: String {
87
- let latency = String(format: "%.3f", self.latency)
88
- let requestDuration = String(format: "%.3f", self.requestDuration)
89
- let serializationDuration = String(format: "%.3f", self.serializationDuration)
90
- let totalDuration = String(format: "%.3f", self.totalDuration)
91
-
92
- // NOTE: Had to move to string concatenation due to memory leak filed as rdar://26761490. Once memory leak is
93
- // fixed, we should move back to string interpolation by reverting commit 7d4a43b1.
94
- let timings = [
95
- "\"Latency\": " + latency + " secs",
96
- "\"Request Duration\": " + requestDuration + " secs",
97
- "\"Serialization Duration\": " + serializationDuration + " secs",
98
- "\"Total Duration\": " + totalDuration + " secs"
99
- ]
100
-
101
- return "Timeline: { " + timings.joined(separator: ", ") + " }"
102
- }
103
- }
104
-
105
- // MARK: - CustomDebugStringConvertible
106
-
107
- extension Timeline: CustomDebugStringConvertible {
108
- /// The textual representation used when written to an output stream, which includes the request start time, the
109
- /// initial response time, the request completed time, the serialization completed time, the latency, the request
110
- /// duration and the total duration.
111
- public var debugDescription: String {
112
- let requestStartTime = String(format: "%.3f", self.requestStartTime)
113
- let initialResponseTime = String(format: "%.3f", self.initialResponseTime)
114
- let requestCompletedTime = String(format: "%.3f", self.requestCompletedTime)
115
- let serializationCompletedTime = String(format: "%.3f", self.serializationCompletedTime)
116
- let latency = String(format: "%.3f", self.latency)
117
- let requestDuration = String(format: "%.3f", self.requestDuration)
118
- let serializationDuration = String(format: "%.3f", self.serializationDuration)
119
- let totalDuration = String(format: "%.3f", self.totalDuration)
120
-
121
- // NOTE: Had to move to string concatenation due to memory leak filed as rdar://26761490. Once memory leak is
122
- // fixed, we should move back to string interpolation by reverting commit 7d4a43b1.
123
- let timings = [
124
- "\"Request Start Time\": " + requestStartTime,
125
- "\"Initial Response Time\": " + initialResponseTime,
126
- "\"Request Completed Time\": " + requestCompletedTime,
127
- "\"Serialization Completed Time\": " + serializationCompletedTime,
128
- "\"Latency\": " + latency + " secs",
129
- "\"Request Duration\": " + requestDuration + " secs",
130
- "\"Serialization Duration\": " + serializationDuration + " secs",
131
- "\"Total Duration\": " + totalDuration + " secs"
132
- ]
133
-
134
- return "Timeline: { " + timings.joined(separator: ", ") + " }"
135
- }
136
- }
@@ -1,315 +0,0 @@
1
- //
2
- // Validation.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
- extension Request {
28
-
29
- // MARK: Helper Types
30
-
31
- fileprivate typealias ErrorReason = AFError.ResponseValidationFailureReason
32
-
33
- /// Used to represent whether validation was successful or encountered an error resulting in a failure.
34
- ///
35
- /// - success: The validation was successful.
36
- /// - failure: The validation failed encountering the provided error.
37
- public enum ValidationResult {
38
- case success
39
- case failure(Error)
40
- }
41
-
42
- fileprivate struct MIMEType {
43
- let type: String
44
- let subtype: String
45
-
46
- var isWildcard: Bool { return type == "*" && subtype == "*" }
47
-
48
- init?(_ string: String) {
49
- let components: [String] = {
50
- let stripped = string.trimmingCharacters(in: .whitespacesAndNewlines)
51
-
52
- #if swift(>=3.2)
53
- let split = stripped[..<(stripped.range(of: ";")?.lowerBound ?? stripped.endIndex)]
54
- #else
55
- let split = stripped.substring(to: stripped.range(of: ";")?.lowerBound ?? stripped.endIndex)
56
- #endif
57
-
58
- return split.components(separatedBy: "/")
59
- }()
60
-
61
- if let type = components.first, let subtype = components.last {
62
- self.type = type
63
- self.subtype = subtype
64
- } else {
65
- return nil
66
- }
67
- }
68
-
69
- func matches(_ mime: MIMEType) -> Bool {
70
- switch (type, subtype) {
71
- case (mime.type, mime.subtype), (mime.type, "*"), ("*", mime.subtype), ("*", "*"):
72
- return true
73
- default:
74
- return false
75
- }
76
- }
77
- }
78
-
79
- // MARK: Properties
80
-
81
- fileprivate var acceptableStatusCodes: [Int] { return Array(200..<300) }
82
-
83
- fileprivate var acceptableContentTypes: [String] {
84
- if let accept = request?.value(forHTTPHeaderField: "Accept") {
85
- return accept.components(separatedBy: ",")
86
- }
87
-
88
- return ["*/*"]
89
- }
90
-
91
- // MARK: Status Code
92
-
93
- fileprivate func validate<S: Sequence>(
94
- statusCode acceptableStatusCodes: S,
95
- response: HTTPURLResponse)
96
- -> ValidationResult
97
- where S.Iterator.Element == Int
98
- {
99
- if acceptableStatusCodes.contains(response.statusCode) {
100
- return .success
101
- } else {
102
- let reason: ErrorReason = .unacceptableStatusCode(code: response.statusCode)
103
- return .failure(AFError.responseValidationFailed(reason: reason))
104
- }
105
- }
106
-
107
- // MARK: Content Type
108
-
109
- fileprivate func validate<S: Sequence>(
110
- contentType acceptableContentTypes: S,
111
- response: HTTPURLResponse,
112
- data: Data?)
113
- -> ValidationResult
114
- where S.Iterator.Element == String
115
- {
116
- guard let data = data, data.count > 0 else { return .success }
117
-
118
- guard
119
- let responseContentType = response.mimeType,
120
- let responseMIMEType = MIMEType(responseContentType)
121
- else {
122
- for contentType in acceptableContentTypes {
123
- if let mimeType = MIMEType(contentType), mimeType.isWildcard {
124
- return .success
125
- }
126
- }
127
-
128
- let error: AFError = {
129
- let reason: ErrorReason = .missingContentType(acceptableContentTypes: Array(acceptableContentTypes))
130
- return AFError.responseValidationFailed(reason: reason)
131
- }()
132
-
133
- return .failure(error)
134
- }
135
-
136
- for contentType in acceptableContentTypes {
137
- if let acceptableMIMEType = MIMEType(contentType), acceptableMIMEType.matches(responseMIMEType) {
138
- return .success
139
- }
140
- }
141
-
142
- let error: AFError = {
143
- let reason: ErrorReason = .unacceptableContentType(
144
- acceptableContentTypes: Array(acceptableContentTypes),
145
- responseContentType: responseContentType
146
- )
147
-
148
- return AFError.responseValidationFailed(reason: reason)
149
- }()
150
-
151
- return .failure(error)
152
- }
153
- }
154
-
155
- // MARK: -
156
-
157
- extension DataRequest {
158
- /// A closure used to validate a request that takes a URL request, a URL response and data, and returns whether the
159
- /// request was valid.
160
- public typealias Validation = (URLRequest?, HTTPURLResponse, Data?) -> ValidationResult
161
-
162
- /// Validates the request, using the specified closure.
163
- ///
164
- /// If validation fails, subsequent calls to response handlers will have an associated error.
165
- ///
166
- /// - parameter validation: A closure to validate the request.
167
- ///
168
- /// - returns: The request.
169
- @discardableResult
170
- public func validate(_ validation: @escaping Validation) -> Self {
171
- let validationExecution: () -> Void = { [unowned self] in
172
- if
173
- let response = self.response,
174
- self.delegate.error == nil,
175
- case let .failure(error) = validation(self.request, response, self.delegate.data)
176
- {
177
- self.delegate.error = error
178
- }
179
- }
180
-
181
- validations.append(validationExecution)
182
-
183
- return self
184
- }
185
-
186
- /// Validates that the response has a status code in the specified sequence.
187
- ///
188
- /// If validation fails, subsequent calls to response handlers will have an associated error.
189
- ///
190
- /// - parameter range: The range of acceptable status codes.
191
- ///
192
- /// - returns: The request.
193
- @discardableResult
194
- public func validate<S: Sequence>(statusCode acceptableStatusCodes: S) -> Self where S.Iterator.Element == Int {
195
- return validate { [unowned self] _, response, _ in
196
- return self.validate(statusCode: acceptableStatusCodes, response: response)
197
- }
198
- }
199
-
200
- /// Validates that the response has a content type in the specified sequence.
201
- ///
202
- /// If validation fails, subsequent calls to response handlers will have an associated error.
203
- ///
204
- /// - parameter contentType: The acceptable content types, which may specify wildcard types and/or subtypes.
205
- ///
206
- /// - returns: The request.
207
- @discardableResult
208
- public func validate<S: Sequence>(contentType acceptableContentTypes: S) -> Self where S.Iterator.Element == String {
209
- return validate { [unowned self] _, response, data in
210
- return self.validate(contentType: acceptableContentTypes, response: response, data: data)
211
- }
212
- }
213
-
214
- /// Validates that the response has a status code in the default acceptable range of 200...299, and that the content
215
- /// type matches any specified in the Accept HTTP header field.
216
- ///
217
- /// If validation fails, subsequent calls to response handlers will have an associated error.
218
- ///
219
- /// - returns: The request.
220
- @discardableResult
221
- public func validate() -> Self {
222
- return validate(statusCode: self.acceptableStatusCodes).validate(contentType: self.acceptableContentTypes)
223
- }
224
- }
225
-
226
- // MARK: -
227
-
228
- extension DownloadRequest {
229
- /// A closure used to validate a request that takes a URL request, a URL response, a temporary URL and a
230
- /// destination URL, and returns whether the request was valid.
231
- public typealias Validation = (
232
- _ request: URLRequest?,
233
- _ response: HTTPURLResponse,
234
- _ temporaryURL: URL?,
235
- _ destinationURL: URL?)
236
- -> ValidationResult
237
-
238
- /// Validates the request, using the specified closure.
239
- ///
240
- /// If validation fails, subsequent calls to response handlers will have an associated error.
241
- ///
242
- /// - parameter validation: A closure to validate the request.
243
- ///
244
- /// - returns: The request.
245
- @discardableResult
246
- public func validate(_ validation: @escaping Validation) -> Self {
247
- let validationExecution: () -> Void = { [unowned self] in
248
- let request = self.request
249
- let temporaryURL = self.downloadDelegate.temporaryURL
250
- let destinationURL = self.downloadDelegate.destinationURL
251
-
252
- if
253
- let response = self.response,
254
- self.delegate.error == nil,
255
- case let .failure(error) = validation(request, response, temporaryURL, destinationURL)
256
- {
257
- self.delegate.error = error
258
- }
259
- }
260
-
261
- validations.append(validationExecution)
262
-
263
- return self
264
- }
265
-
266
- /// Validates that the response has a status code in the specified sequence.
267
- ///
268
- /// If validation fails, subsequent calls to response handlers will have an associated error.
269
- ///
270
- /// - parameter range: The range of acceptable status codes.
271
- ///
272
- /// - returns: The request.
273
- @discardableResult
274
- public func validate<S: Sequence>(statusCode acceptableStatusCodes: S) -> Self where S.Iterator.Element == Int {
275
- return validate { [unowned self] _, response, _, _ in
276
- return self.validate(statusCode: acceptableStatusCodes, response: response)
277
- }
278
- }
279
-
280
- /// Validates that the response has a content type in the specified sequence.
281
- ///
282
- /// If validation fails, subsequent calls to response handlers will have an associated error.
283
- ///
284
- /// - parameter contentType: The acceptable content types, which may specify wildcard types and/or subtypes.
285
- ///
286
- /// - returns: The request.
287
- @discardableResult
288
- public func validate<S: Sequence>(contentType acceptableContentTypes: S) -> Self where S.Iterator.Element == String {
289
- return validate { [unowned self] _, response, _, _ in
290
- let fileURL = self.downloadDelegate.fileURL
291
-
292
- guard let validFileURL = fileURL else {
293
- return .failure(AFError.responseValidationFailed(reason: .dataFileNil))
294
- }
295
-
296
- do {
297
- let data = try Data(contentsOf: validFileURL)
298
- return self.validate(contentType: acceptableContentTypes, response: response, data: data)
299
- } catch {
300
- return .failure(AFError.responseValidationFailed(reason: .dataFileReadFailed(at: validFileURL)))
301
- }
302
- }
303
- }
304
-
305
- /// Validates that the response has a status code in the default acceptable range of 200...299, and that the content
306
- /// type matches any specified in the Accept HTTP header field.
307
- ///
308
- /// If validation fails, subsequent calls to response handlers will have an associated error.
309
- ///
310
- /// - returns: The request.
311
- @discardableResult
312
- public func validate() -> Self {
313
- return validate(statusCode: self.acceptableStatusCodes).validate(contentType: self.acceptableContentTypes)
314
- }
315
- }