Skip to content

Commit

Permalink
remove .character from file and templates and build exec file without…
Browse files Browse the repository at this point in the history
… .character included
  • Loading branch information
chamnan1111 committed Aug 31, 2023
1 parent 92d6cff commit 71fafb5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions Sources/SwiftyMocky/Mock.swifttemplate
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class Helpers {
}
static func extractGenericsList(_ associatedTypes: [String]?) -> [String] {
return associatedTypes?.flatMap {
split($0, byFirstOccurenceOf: " where ").0.replacingOccurrences(of: " ", with: "").characters.split(separator: ":").map(String.init).first
split($0, byFirstOccurenceOf: " where ").0.replacingOccurrences(of: " ", with: "")s.split(separator: ":").map(String.init).first
}.map { "\($0)" } ?? []
}
static func extractGenericTypesModifier(_ associatedTypes: [String]?) -> String {
Expand All @@ -253,9 +253,9 @@ class Helpers {
guard let all = associatedTypes else { return "" }
let constraints = all.flatMap { t -> String? in
let splitted = split(t, byFirstOccurenceOf: " where ")
let constraint = splitted.0.replacingOccurrences(of: " ", with: "").characters.split(separator: ":").map(String.init)
let constraint = splitted.0.replacingOccurrences(of: " ", with: "")s.split(separator: ":").map(String.init)
guard constraint.count == 2 else { return nil }
let adopts = constraint[1].characters.split(separator: ",").map(String.init)
let adopts = constraint[1]s.split(separator: ",").map(String.init)
var mapped = adopts.map { "\(constraint[0]): \($0)" }
if !splitted.1.isEmpty {
mapped.append(splitted.1)
Expand Down Expand Up @@ -1146,7 +1146,7 @@ class MethodWrapper {
genPart.removeFirst()
genPart.removeLast()

let parts = genPart.replacingOccurrences(of: " ", with: "").characters.split(separator: ",").map(String.init)
let parts = genPart.replacingOccurrences(of: " ", with: "")s.split(separator: ",").map(String.init)
return parts.map { stripGenPart(part: $0) }
}

Expand All @@ -1161,7 +1161,7 @@ class MethodWrapper {
genPart.removeFirst()
genPart.removeLast()

let parts = genPart.replacingOccurrences(of: " ", with: "").characters.split(separator: ",").map(String.init)
let parts = genPart.replacingOccurrences(of: " ", with: "")s.split(separator: ",").map(String.init)
return parts.filter {
let components = $0.components(separatedBy: ":")
return (components.count == 2 || !filterSingle) && generics.contains(components[0])
Expand All @@ -1183,7 +1183,7 @@ class MethodWrapper {
}

private func stripGenPart(part: String) -> String {
return part.characters.split(separator: ":").map(String.init).first!
return parts.split(separator: ":").map(String.init).first!
}

private func returnTypeStripped(_ method: SourceryRuntime.Method, type: Bool = false) -> String {
Expand Down
12 changes: 6 additions & 6 deletions Sources/SwiftyPrototype/Prototype.swifttemplate
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class Helpers {
}
static func extractGenericsList(_ associatedTypes: [String]?) -> [String] {
return associatedTypes?.flatMap {
split($0, byFirstOccurenceOf: " where ").0.replacingOccurrences(of: " ", with: "").characters.split(separator: ":").map(String.init).first
split($0, byFirstOccurenceOf: " where ").0.replacingOccurrences(of: " ", with: "")s.split(separator: ":").map(String.init).first
}.map { "\($0)" } ?? []
}
static func extractGenericTypesModifier(_ associatedTypes: [String]?) -> String {
Expand All @@ -252,9 +252,9 @@ class Helpers {
guard let all = associatedTypes else { return "" }
let constraints = all.flatMap { t -> String? in
let splitted = split(t, byFirstOccurenceOf: " where ")
let constraint = splitted.0.replacingOccurrences(of: " ", with: "").characters.split(separator: ":").map(String.init)
let constraint = splitted.0.replacingOccurrences(of: " ", with: "")s.split(separator: ":").map(String.init)
guard constraint.count == 2 else { return nil }
let adopts = constraint[1].characters.split(separator: ",").map(String.init)
let adopts = constraint[1]s.split(separator: ",").map(String.init)
var mapped = adopts.map { "\(constraint[0]): \($0)" }
if !splitted.1.isEmpty {
mapped.append(splitted.1)
Expand Down Expand Up @@ -1145,7 +1145,7 @@ class MethodWrapper {
genPart.removeFirst()
genPart.removeLast()

let parts = genPart.replacingOccurrences(of: " ", with: "").characters.split(separator: ",").map(String.init)
let parts = genPart.replacingOccurrences(of: " ", with: "")s.split(separator: ",").map(String.init)
return parts.map { stripGenPart(part: $0) }
}

Expand All @@ -1160,7 +1160,7 @@ class MethodWrapper {
genPart.removeFirst()
genPart.removeLast()

let parts = genPart.replacingOccurrences(of: " ", with: "").characters.split(separator: ",").map(String.init)
let parts = genPart.replacingOccurrences(of: " ", with: "")s.split(separator: ",").map(String.init)
return parts.filter {
let components = $0.components(separatedBy: ":")
return (components.count == 2 || !filterSingle) && generics.contains(components[0])
Expand All @@ -1182,7 +1182,7 @@ class MethodWrapper {
}

private func stripGenPart(part: String) -> String {
return part.characters.split(separator: ":").map(String.init).first!
return parts.split(separator: ":").map(String.init).first!
}

private func returnTypeStripped(_ method: SourceryRuntime.Method, type: Bool = false) -> String {
Expand Down
6 changes: 3 additions & 3 deletions Templates/Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Helpers {
}
static func extractGenericsList(_ associatedTypes: [String]?) -> [String] {
return associatedTypes?.flatMap {
split($0, byFirstOccurenceOf: " where ").0.replacingOccurrences(of: " ", with: "").characters.split(separator: ":").map(String.init).first
split($0, byFirstOccurenceOf: " where ").0.replacingOccurrences(of: " ", with: "")s.split(separator: ":").map(String.init).first
}.map { "\($0)" } ?? []
}
static func extractGenericTypesModifier(_ associatedTypes: [String]?) -> String {
Expand All @@ -48,9 +48,9 @@ class Helpers {
guard let all = associatedTypes else { return "" }
let constraints = all.flatMap { t -> String? in
let splitted = split(t, byFirstOccurenceOf: " where ")
let constraint = splitted.0.replacingOccurrences(of: " ", with: "").characters.split(separator: ":").map(String.init)
let constraint = splitted.0.replacingOccurrences(of: " ", with: "")s.split(separator: ":").map(String.init)
guard constraint.count == 2 else { return nil }
let adopts = constraint[1].characters.split(separator: ",").map(String.init)
let adopts = constraint[1]s.split(separator: ",").map(String.init)
var mapped = adopts.map { "\(constraint[0]): \($0)" }
if !splitted.1.isEmpty {
mapped.append(splitted.1)
Expand Down
6 changes: 3 additions & 3 deletions Templates/MethodWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ class MethodWrapper {
genPart.removeFirst()
genPart.removeLast()

let parts = genPart.replacingOccurrences(of: " ", with: "").characters.split(separator: ",").map(String.init)
let parts = genPart.replacingOccurrences(of: " ", with: "")s.split(separator: ",").map(String.init)
return parts.map { stripGenPart(part: $0) }
}

Expand All @@ -656,7 +656,7 @@ class MethodWrapper {
genPart.removeFirst()
genPart.removeLast()

let parts = genPart.replacingOccurrences(of: " ", with: "").characters.split(separator: ",").map(String.init)
let parts = genPart.replacingOccurrences(of: " ", with: "")s.split(separator: ",").map(String.init)
return parts.filter {
let components = $0.components(separatedBy: ":")
return (components.count == 2 || !filterSingle) && generics.contains(components[0])
Expand All @@ -678,7 +678,7 @@ class MethodWrapper {
}

private func stripGenPart(part: String) -> String {
return part.characters.split(separator: ":").map(String.init).first!
return parts.split(separator: ":").map(String.init).first!
}

private func returnTypeStripped(_ method: SourceryRuntime.Method, type: Bool = false) -> String {
Expand Down
Binary file modified bin/swiftymocky
Binary file not shown.

0 comments on commit 71fafb5

Please sign in to comment.