-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from mackoj/feat/addSupportForTests
Add support for tests
- Loading branch information
Showing
5 changed files
with
68 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import Foundation | ||
|
||
public struct PackageInformation: Codable { | ||
public struct PathInfo: Codable { | ||
public let path: String | ||
public let name: String | ||
} | ||
public let test: PathInfo? | ||
public let target: PathInfo | ||
|
||
public init(from decoder: any Decoder) throws { | ||
// Legacy Parser | ||
let stringContainer = try decoder.singleValueContainer() | ||
if let pathString = try? stringContainer.decode(String.self) { | ||
let path = URL(fileURLWithPath: pathString) | ||
self.target = PathInfo(path: pathString, name: path.lastPathComponent) | ||
self.test = nil | ||
return | ||
} | ||
|
||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
self.test = try container.decodeIfPresent(PackageInformation.PathInfo.self, forKey: .test) | ||
self.target = try container.decode(PackageInformation.PathInfo.self, forKey: .target) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,31 @@ | ||
import Foundation | ||
|
||
struct ParsedPackage: Codable, CustomStringConvertible { | ||
var name: String | ||
var dependencies: [String] | ||
var path: String | ||
var fullPath: String | ||
var localDependencies: Int = 0 | ||
var hasBiggestNumberOfDependencies: Bool = false | ||
public struct ParsedPackage: Codable, CustomStringConvertible { | ||
public var name: String | ||
public var test: PackageInformation.PathInfo? | ||
public var dependencies: [String] | ||
public var path: String | ||
public var fullPath: String | ||
public var resources: String? | ||
public var localDependencies: Int = 0 | ||
public var hasBiggestNumberOfDependencies: Bool = false | ||
|
||
var description: String { | ||
"[\(dependencies.count)|\(localDependencies)] \(name)" | ||
public var hasResources: Bool { | ||
resources != nil && resources!.isEmpty == false | ||
} | ||
|
||
public var description: String { | ||
"[\(dependencies.count)|\(localDependencies)] \(name) \(hasResources == false ? "" : "/ hasResources")" | ||
} | ||
|
||
public init(name: String, test: PackageInformation.PathInfo? = nil, dependencies: [String], path: String, fullPath: String, resources: String? = nil, localDependencies: Int = 0, hasBiggestNumberOfDependencies: Bool = false) { | ||
self.name = name | ||
self.test = test | ||
self.dependencies = dependencies | ||
self.path = path | ||
self.fullPath = fullPath | ||
self.resources = resources | ||
self.localDependencies = localDependencies | ||
self.hasBiggestNumberOfDependencies = hasBiggestNumberOfDependencies | ||
} | ||
} |