diff --git a/SourceryExample.xcodeproj/project.xcworkspace/xcuserdata/Pessoal.xcuserdatad/UserInterfaceState.xcuserstate b/SourceryExample.xcodeproj/project.xcworkspace/xcuserdata/Pessoal.xcuserdatad/UserInterfaceState.xcuserstate index 98c8f88..837a4c3 100644 Binary files a/SourceryExample.xcodeproj/project.xcworkspace/xcuserdata/Pessoal.xcuserdatad/UserInterfaceState.xcuserstate and b/SourceryExample.xcodeproj/project.xcworkspace/xcuserdata/Pessoal.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/SourceryExample/Autogenerated/AutoDecodable.generated.swift b/SourceryExample/Autogenerated/AutoDecodable.generated.swift index 8c3cff9..2045ba3 100644 --- a/SourceryExample/Autogenerated/AutoDecodable.generated.swift +++ b/SourceryExample/Autogenerated/AutoDecodable.generated.swift @@ -1,81 +1,2 @@ // Generated using Sourcery 0.18.0 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT - - -// MARK: - Decodable for BaseComponent -extension BaseComponent { - - enum CodingKeys: String, CodingKey { - case baseName - case baseDescription - case alignement - case size - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - baseName = try container.decodeIfPresent(String.self, forKey: .baseName) - baseDescription = try container.decodeIfPresent(String.self, forKey: .baseDescription) - alignement = try container.decode(Alignement.self, forKey: .alignement) - size = try container.decode(Size.self, forKey: .size) - - } -} - -// MARK: - Decodable for ChildComponent1 -extension ChildComponent1 { - - enum CodingKeys: String, CodingKey { - case attributeOne - case attributeTwo - case baseProperties - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - attributeOne = try container.decode(String.self, forKey: .attributeOne) - attributeTwo = try container.decodeIfPresent(Float.self, forKey: .attributeTwo) - baseProperties = try container.decodeIfPresent(BaseComponent.self, forKey: .baseProperties) - - } -} - -// MARK: - Decodable for ChildComponent2 -extension ChildComponent2 { - - enum CodingKeys: String, CodingKey { - case attributeThree - case attributeFour - case baseProperties - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - attributeThree = try container.decode(String.self, forKey: .attributeThree) - attributeFour = try container.decode(Float.self, forKey: .attributeFour) - baseProperties = try container.decodeIfPresent(BaseComponent.self, forKey: .baseProperties) - - } -} - -// MARK: - Decodable for ChildComponent3 -extension ChildComponent3 { - - enum CodingKeys: String, CodingKey { - case baseProperties - case importantAttribute - case notImportantAttribute - } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - baseProperties = try container.decodeIfPresent(BaseComponent.self, forKey: .baseProperties) - importantAttribute = try container.decode([String: String].self, forKey: .importantAttribute) - notImportantAttribute = nil - - } -} diff --git a/SourceryExample/Autogenerated/AutoEquatable.generated.swift b/SourceryExample/Autogenerated/AutoEquatable.generated.swift index 9b916b8..2045ba3 100644 --- a/SourceryExample/Autogenerated/AutoEquatable.generated.swift +++ b/SourceryExample/Autogenerated/AutoEquatable.generated.swift @@ -1,44 +1,2 @@ // Generated using Sourcery 0.18.0 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT - - - -// MARK: BaseComponent Equatable -extension BaseComponent: Equatable { - public static func ==(lhs: BaseComponent, rhs: BaseComponent) -> Bool { - guard lhs.baseName == rhs.baseName else { return false } - guard lhs.baseDescription == rhs.baseDescription else { return false } - guard lhs.alignement == rhs.alignement else { return false } - guard lhs.size == rhs.size else { return false } - return true - } -} - -// MARK: ChildComponent1 Equatable -extension ChildComponent1: Equatable { - public static func ==(lhs: ChildComponent1, rhs: ChildComponent1) -> Bool { - guard lhs.attributeOne == rhs.attributeOne else { return false } - guard lhs.attributeTwo == rhs.attributeTwo else { return false } - guard lhs.baseProperties == rhs.baseProperties else { return false } - return true - } -} - -// MARK: ChildComponent2 Equatable -extension ChildComponent2: Equatable { - public static func ==(lhs: ChildComponent2, rhs: ChildComponent2) -> Bool { - guard lhs.attributeThree == rhs.attributeThree else { return false } - guard lhs.attributeFour == rhs.attributeFour else { return false } - guard lhs.baseProperties == rhs.baseProperties else { return false } - return true - } -} - -// MARK: ChildComponent3 Equatable -extension ChildComponent3: Equatable { - public static func ==(lhs: ChildComponent3, rhs: ChildComponent3) -> Bool { - guard lhs.baseProperties == rhs.baseProperties else { return false } - guard lhs.importantAttribute == rhs.importantAttribute else { return false } - return true - } -} diff --git a/SourceryExample/Autogenerated/AutoMockable.generated.swift b/SourceryExample/Autogenerated/AutoMockable.generated.swift index 4750ef0..89654da 100644 --- a/SourceryExample/Autogenerated/AutoMockable.generated.swift +++ b/SourceryExample/Autogenerated/AutoMockable.generated.swift @@ -25,39 +25,3 @@ import AppKit -class NetworkDispatcherMock: NetworkDispatcher { - var baseUrl: URL { - get { return underlyingBaseUrl } - set(value) { underlyingBaseUrl = value } - } - var underlyingBaseUrl: URL! - - //MARK: - init - - var initBaseUrlReceivedBaseUrl: String? - var initBaseUrlReceivedInvocations: [String] = [] - var initBaseUrlClosure: ((String) -> Void)? - - required init(baseUrl: String) { - initBaseUrlReceivedBaseUrl = baseUrl - initBaseUrlReceivedInvocations.append(baseUrl) - initBaseUrlClosure?(baseUrl) - } - //MARK: - request - - var requestMethodHeadersOnCompletionCallsCount = 0 - var requestMethodHeadersOnCompletionCalled: Bool { - return requestMethodHeadersOnCompletionCallsCount > 0 - } - var requestMethodHeadersOnCompletionReceivedArguments: (method: HTTPMethod, headers: Headers?, onCompletion: (Result)?)? - var requestMethodHeadersOnCompletionReceivedInvocations: [(method: HTTPMethod, headers: Headers?, onCompletion: (Result)?)] = [] - var requestMethodHeadersOnCompletionClosure: ((HTTPMethod, Headers?, (Result)?) -> Void)? - - func request(method: HTTPMethod, headers: Headers?, onCompletion: (Result)?) { - requestMethodHeadersOnCompletionCallsCount += 1 - requestMethodHeadersOnCompletionReceivedArguments = (method: method, headers: headers, onCompletion: onCompletion) - requestMethodHeadersOnCompletionReceivedInvocations.append((method: method, headers: headers, onCompletion: onCompletion)) - requestMethodHeadersOnCompletionClosure?(method, headers, onCompletion) - } - -} diff --git a/SourceryExample/Models/Base.swift b/SourceryExample/Models/Base.swift index 5be7a69..02f33e1 100644 --- a/SourceryExample/Models/Base.swift +++ b/SourceryExample/Models/Base.swift @@ -18,49 +18,16 @@ public enum Alignement: String, Decodable, Equatable { case horizontal } -public struct Size: Decodable, Equatable, AutoInitiable { - +public struct Size: Decodable, Equatable { var width: Double var maxWidth: Double var height: Double var maxHeight: Double - -// sourcery:inline:auto:Size.Init - -// MARK: - Size custom init - public init( - width: Double, - maxWidth: Double, - height: Double, - maxHeight: Double - ) { - self.width = width - self.maxWidth = maxWidth - self.height = height - self.maxHeight = maxHeight - } -// sourcery:end } -public struct BaseComponent: AutoEquatable, AutoInitiable, AutoDecodable { +public struct BaseComponent { public var baseName: String? public var baseDescription: String? public var alignement: Alignement = .horizontal public var size: Size - -// sourcery:inline:auto:BaseComponent.Init - -// MARK: - BaseComponent custom init - public init( - baseName: String? = nil, - baseDescription: String? = nil, - alignement: Alignement = .horizontal, - size: Size - ) { - self.baseName = baseName - self.baseDescription = baseDescription - self.alignement = alignement - self.size = size - } -// sourcery:end } diff --git a/SourceryExample/Models/Models.swift b/SourceryExample/Models/Models.swift index 77fbd96..b41b740 100644 --- a/SourceryExample/Models/Models.swift +++ b/SourceryExample/Models/Models.swift @@ -8,49 +8,20 @@ import Foundation -public struct ChildComponent1: BaseProperties, AutoEquatable, AutoDecodable { +public struct ChildComponent1: BaseProperties { let attributeOne: String let attributeTwo: Float? public var baseProperties: BaseComponent? } -public struct ChildComponent2: BaseProperties, AutoEquatable, AutoDecodable, AutoInitiable { +public struct ChildComponent2: BaseProperties { let attributeThree: String let attributeFour: Float public var baseProperties: BaseComponent? - -// sourcery:inline:auto:ChildComponent2.Init - -// MARK: - ChildComponent2 custom init - public init( - attributeThree: String, - attributeFour: Float, - baseProperties: BaseComponent? = nil - ) { - self.attributeThree = attributeThree - self.attributeFour = attributeFour - self.baseProperties = baseProperties - } -// sourcery:end } -public struct ChildComponent3: BaseProperties, AutoEquatable, AutoInitiable, AutoDecodable { +public struct ChildComponent3: BaseProperties { public var baseProperties: BaseComponent? public var importantAttribute: [String: String] - // sourcery: skipEquality, skipDecodable public var notImportantAttribute: [String: String]? - -// sourcery:inline:auto:ChildComponent3.Init - -// MARK: - ChildComponent3 custom init - public init( - baseProperties: BaseComponent? = nil, - importantAttribute: [String: String], - notImportantAttribute: [String: String]? = nil - ) { - self.baseProperties = baseProperties - self.importantAttribute = importantAttribute - self.notImportantAttribute = notImportantAttribute - } -// sourcery:end } diff --git a/SourceryExample/Network/Network.swift b/SourceryExample/Network/Network.swift index 4fa7e7b..29d2e0a 100644 --- a/SourceryExample/Network/Network.swift +++ b/SourceryExample/Network/Network.swift @@ -17,7 +17,7 @@ public enum HTTPMethod: String { public typealias Headers = [String:String] -protocol NetworkDispatcher: AutoMockable { +protocol NetworkDispatcher { var baseUrl: URL { get } init(baseUrl: String) func request(method: HTTPMethod, headers: Headers?, onCompletion: (Result)?)