From ea906f7515e596bf2cb825426dc7eb4c2d115aa7 Mon Sep 17 00:00:00 2001 From: Jason Grandelli Date: Mon, 14 Nov 2016 18:53:14 -0500 Subject: [PATCH] Renaming to and spelling fix. --- MarshalTests/MarshalTests.swift | 10 +++++----- Sources/MarshaledObject.swift | 8 ++++---- Sources/ValueType.swift | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/MarshalTests/MarshalTests.swift b/MarshalTests/MarshalTests.swift index ec6da81..53b27f8 100644 --- a/MarshalTests/MarshalTests.swift +++ b/MarshalTests/MarshalTests.swift @@ -398,7 +398,7 @@ class MarshalTests: XCTestCase { let optionalArrayOfOptionalCars: [Car?]? = try? json.value(for: "cars") XCTAssertNotNil(optionalArrayOfOptionalCars, "optionalArrayOfOptionalCars should not be nil") XCTAssert(optionalArrayOfOptionalCars?.count == 8, "optionalArrayOfOptionalCars should have 8 objects. Actual count = \(optionalArrayOfOptionalCars?.count)") - XCTAssert(optionalArrayOfOptionalCars?.contains(where: { $0?.make == "Lexus" }) == false, "optionalArrayOfOptionalCars should not contain a Lexus becasue the Lexus was malformed") + XCTAssert(optionalArrayOfOptionalCars?.contains(where: { $0?.make == "Lexus" }) == false, "optionalArrayOfOptionalCars should not contain a Lexus because the Lexus was malformed") XCTAssert(optionalArrayOfOptionalCars?[1] == nil, "optionalArrayOfOptionalCars[1] should be nil") do { @@ -406,7 +406,7 @@ class MarshalTests: XCTestCase { XCTAssertNotNil(arrayOfOptionalCars, "arrayOfOptionalCars should not be nil") XCTAssert(arrayOfOptionalCars.count == 8, "arrayOfOptionalCars should have 8 objects. Actual count = \(optionalArrayOfOptionalCars?.count)") - XCTAssert(arrayOfOptionalCars.contains(where: { $0?.make == "Lexus" }) == false, "arrayOfOptionalCars should not contain a Lexus becasue the Lexus was malformed") + XCTAssert(arrayOfOptionalCars.contains(where: { $0?.make == "Lexus" }) == false, "arrayOfOptionalCars should not contain a Lexus because the Lexus was malformed") XCTAssert(arrayOfOptionalCars[1] == nil, "arrayOfOptionalCars[1] should be nil") } catch { @@ -414,7 +414,7 @@ class MarshalTests: XCTestCase { } } - func testDiscardingInvalidObjects() { + func testDiscardingErrors() { guard let path = Bundle(for: type(of: self)).path(forResource: "TestMissingData", ofType: "json"), let data = try? Data(contentsOf: URL(fileURLWithPath: path)), let json = try? JSONParser.JSONObjectWithData(data) else { @@ -422,9 +422,9 @@ class MarshalTests: XCTestCase { return } - let arrayOfCarsWithoutInvalidObjects: [Car]? = try? json.value(for: "cars", discardInvalidObjects: true) + let arrayOfCarsWithoutInvalidObjects: [Car]? = try? json.value(for: "cars", discardingErrors: true) XCTAssert(arrayOfCarsWithoutInvalidObjects?.count == 5, "arrayOfCarsWithoutInvalidObjects should have 5 objects. Actual count = \(arrayOfCarsWithoutInvalidObjects?.count)") - XCTAssert(arrayOfCarsWithoutInvalidObjects?.contains(where: { $0.make == "Lexus" }) == false, "arrayOfCarsWithoutInvalidObjects should not contain a Lexus becasue the Lexus was malformed") + XCTAssert(arrayOfCarsWithoutInvalidObjects?.contains(where: { $0.make == "Lexus" }) == false, "arrayOfCarsWithoutInvalidObjects should not contain a Lexus because the Lexus was malformed") } } diff --git a/Sources/MarshaledObject.swift b/Sources/MarshaledObject.swift index a97cb15..59a5ad8 100644 --- a/Sources/MarshaledObject.swift +++ b/Sources/MarshaledObject.swift @@ -64,10 +64,10 @@ public extension MarshaledObject { } } - public func value(for key: KeyType, discardInvalidObjects: Bool = false) throws -> [A] { + public func value(for key: KeyType, discardingErrors: Bool = false) throws -> [A] { let any = try self.any(for: key) do { - return try Array.value(from: any, discardInvalidObjects: discardInvalidObjects) + return try Array.value(from: any, discardingErrors: discardingErrors) } catch let MarshalError.typeMismatch(expected: expected, actual: actual) { throw MarshalError.typeMismatchWithKey(key: key.stringValue, expected: expected, actual: actual) @@ -84,9 +84,9 @@ public extension MarshaledObject { } } - public func value(for key: KeyType, discardInvalidObjects: Bool = false) throws -> [A]? { + public func value(for key: KeyType, discardingErrors: Bool = false) throws -> [A]? { do { - return try self.value(for: key, discardInvalidObjects: discardInvalidObjects) as [A] + return try self.value(for: key, discardingErrors: discardingErrors) as [A] } catch MarshalError.keyNotFound { return nil diff --git a/Sources/ValueType.swift b/Sources/ValueType.swift index 120e004..27a4504 100644 --- a/Sources/ValueType.swift +++ b/Sources/ValueType.swift @@ -49,12 +49,12 @@ extension Int64: ValueType { } extension Array where Element: ValueType { - public static func value(from object: Any, discardInvalidObjects: Bool = false) throws -> [Element] { + public static func value(from object: Any, discardingErrors: Bool = false) throws -> [Element] { guard let anyArray = object as? [AnyObject] else { throw MarshalError.typeMismatch(expected: self, actual: type(of: object)) } - if discardInvalidObjects { + if discardingErrors { return anyArray.flatMap { let value = try? Element.value(from: $0) guard let element = value as? Element else {