Closed Ibrahimhass closed 1 year ago
Name | Link |
---|---|
Latest commit | f91f4247046bcf31a61ea4a859968025e61fb5ad |
Latest deploy log | https://app.netlify.com/sites/xcodeproj/deploys/64db7abee8cb840007561e78 |
Deploy Preview | https://deploy-preview-787--xcodeproj.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
@kwridan Thanks for the suggestion :)
Looking further, I found that the underlying type for Writable here is Data
.
So shall we have stringRepresentation()
as an Optional requirement for Writable?
Something similar to this:
/// Protocol that defines how an entity can be written to disk
public protocol Writable {
/// Writes the object that conforms the protocol.
///
/// - Parameter path: The path to write to
/// - Parameter override: True if the content should be overridden if it already exists.
/// - Throws: writing error if something goes wrong.
func write(path: Path, override: Bool) throws
/// Writes the object that conforms the protocol.
///
/// - Parameter pathString: The path string to write to
/// - Parameter override: True if the content should be overridden if it already exists.
/// - Throws: writing error if something goes wrong.
func write(pathString: String, override: Bool) throws
/// Gets the string representation of the object that conforms the protocol.
///
/// - Throws: error if encoding to String goes wrong.
func stringRepresentation() throws -> String
}
extension Writable {
public func write(pathString: String, override: Bool) throws {
let path = Path(pathString)
try write(path: path, override: override)
}
public func stringRepresentation() throws -> String { "" }
}
@kwridan Thanks for the suggestion :) Looking further, I found that the underlying type for Writable here is Data. So shall we have stringRepresentation() as an Optional requirement for Writable?
Thanks for looking further into this would making dataRepresentation()
be a better fit then?
@kwridan
Thanks for looking further into this. Would making dataRepresentation() be a better fit then?
Thanks for the suggestion. Yes, this could work, we modify Writable to something like:
/// Protocol that defines how an entity can be written to disk
public protocol Writable {
/// Writes the object that conforms the protocol.
///
/// - Parameter path: The path to write to
/// - Parameter override: True if the content should be overridden if it already exists.
/// - Throws: writing error if something goes wrong.
func write(path: Path, override: Bool) throws
/// Writes the object that conforms the protocol.
///
/// - Parameter pathString: The path string to write to
/// - Parameter override: True if the content should be overridden if it already exists.
/// - Throws: writing error if something goes wrong.
func write(pathString: String, override: Bool) throws
/// Gets the data representation of the object that conforms to the protocol.
///
/// - Throws: error if encoding to Data goes wrong.
func dataRepresentation() throws -> Data
}
The representation can be used to get the string representation of any of the file if required.
@kwridan Please review the changes here.
@all-contributors add @Ibrahimhass for code
@kwridan
I've put up a pull request to add @Ibrahimhass! :tada:
Resolves https://github.com/tuist/XcodeProj/issues/786
Short description š
Solution š¦
Implementation š©āš»šØāš»