Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
79 changes: 0 additions & 79 deletions SourceryExample/Autogenerated/AutoDecodable.generated.swift
Original file line number Diff line number Diff line change
@@ -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

}
}
42 changes: 0 additions & 42 deletions SourceryExample/Autogenerated/AutoEquatable.generated.swift
Original file line number Diff line number Diff line change
@@ -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
}
}
36 changes: 0 additions & 36 deletions SourceryExample/Autogenerated/AutoMockable.generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Data?, Error>)?)?
var requestMethodHeadersOnCompletionReceivedInvocations: [(method: HTTPMethod, headers: Headers?, onCompletion: (Result<Data?, Error>)?)] = []
var requestMethodHeadersOnCompletionClosure: ((HTTPMethod, Headers?, (Result<Data?, Error>)?) -> Void)?

func request(method: HTTPMethod, headers: Headers?, onCompletion: (Result<Data?, Error>)?) {
requestMethodHeadersOnCompletionCallsCount += 1
requestMethodHeadersOnCompletionReceivedArguments = (method: method, headers: headers, onCompletion: onCompletion)
requestMethodHeadersOnCompletionReceivedInvocations.append((method: method, headers: headers, onCompletion: onCompletion))
requestMethodHeadersOnCompletionClosure?(method, headers, onCompletion)
}

}
37 changes: 2 additions & 35 deletions SourceryExample/Models/Base.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
35 changes: 3 additions & 32 deletions SourceryExample/Models/Models.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion SourceryExample/Network/Network.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Data?, Error>)?)
Expand Down