-
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 #7 from Ether-CLI/develop
Codable Types
- Loading branch information
Showing
64 changed files
with
4,973 additions
and
373 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,31 @@ | ||
extension Manifest { | ||
|
||
/// Keys for encoding a `Manifest` instance. | ||
public typealias CodingKeys = ManifestCodingKeys | ||
} | ||
|
||
/// Keys for encoding a `Manifest` instance. | ||
public enum ManifestCodingKeys: String, CodingKey { | ||
|
||
/// | ||
case name | ||
|
||
/// | ||
case pkgConfig | ||
|
||
/// | ||
case providers | ||
|
||
/// | ||
case products | ||
|
||
/// | ||
case dependencies | ||
|
||
/// | ||
case targets | ||
} | ||
|
||
internal enum ManifestDecodingKeys: String, CodingKey { | ||
case manifest | ||
} |
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,28 @@ | ||
import Foundation | ||
import Utilities | ||
|
||
extension Manifest { | ||
|
||
/// Get all the elements in `Package.providers` from the project's manifest. | ||
/// | ||
/// - Returns: `Package.providers` | ||
/// - Throws: Errors that occur when creating a RegEx pattern | ||
/// or reading or writing the manifest. | ||
public func providers()throws -> [Provider] { | ||
let brew = try NSRegularExpression(pattern: "\\.brew\\((\\[.*?\\])\\)", options: []) | ||
let apt = try NSRegularExpression(pattern: "\\.apt\\((\\[.*?\\])\\)", options: []) | ||
let contents: String = try self.contents() | ||
|
||
let brewProviders: [Provider] = brew.matches(in: contents, options: [], range: contents.range).map { (match) in | ||
let packages = contents.parseArray(at: match.range(at: 1)) | ||
return Provider(type: .brew, packages: packages, manifest: self) | ||
} | ||
let aptProviders: [Provider] = apt.matches(in: contents, options: [], range: contents.range).map { (match) in | ||
let packages = contents.parseArray(at: match.range(at: 1)) | ||
return Provider(type: .apt, packages: packages, manifest: self) | ||
} | ||
|
||
return brewProviders + aptProviders | ||
} | ||
} | ||
|
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
Oops, something went wrong.