Skip to content

Commit

Permalink
Address PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
JustEatTakeawayiOS committed Aug 29, 2024
1 parent ec1cb13 commit 3448c72
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 210 deletions.
193 changes: 0 additions & 193 deletions README.md.orig

This file was deleted.

34 changes: 17 additions & 17 deletions Sources/Core/SpecGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import Yams

/// Class to generate Specs models that can be used to ultimately generate `Package.swift` files.
final class SpecGenerator {

enum GeneratorError: Error {
case invalidFormat(String)
}

let specUrl: URL
let dependenciesUrl: URL

/// The default initializer.
///
/// - Parameters:
Expand All @@ -29,22 +29,22 @@ final class SpecGenerator {
func makeSpec() throws -> Spec {
let spec: Spec = try decodeModel(from: specUrl)
let dependencies: Dependencies = try decodeModel(from: dependenciesUrl)

let mappedDependencies: [Spec.RemoteDependency] = spec.remoteDependencies
.compactMap { remoteDependency -> Spec.RemoteDependency? in
guard let dependency = dependencies.dependencies.first(where: {
$0.name == remoteDependency.name
}) else {
return nil
}
guard let dependency = dependencies.dependencies.first(where: {
$0.name == remoteDependency.name
}) else {
return nil
}
return Spec.RemoteDependency(
name: dependency.name,
url: remoteDependency.url ?? dependency.url,
version: remoteDependency.version ?? dependency.version,
revision: remoteDependency.revision ?? dependency.revision,
branch: remoteDependency.branch ?? dependency.branch
)
}
name: dependency.name,
url: remoteDependency.url ?? dependency.url,
version: remoteDependency.version ?? dependency.version,
revision: remoteDependency.revision ?? dependency.revision,
branch: remoteDependency.branch ?? dependency.branch
)
}

return Spec(
name: spec.name,
Expand All @@ -59,7 +59,7 @@ final class SpecGenerator {
swiftLanguageVersions: spec.swiftLanguageVersions
)
}

private func decodeModel<T: Decodable>(from url: URL) throws -> T {
let specData = try Data(contentsOf: url)
switch url.pathExtension {
Expand Down

0 comments on commit 3448c72

Please sign in to comment.