Skip to content

Commit

Permalink
Fixed level privacy
Browse files Browse the repository at this point in the history
  • Loading branch information
tzopiz committed Jul 8, 2024
1 parent 54c3360 commit 6432dfd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Sources/FileCache/CSVParsing/CSVParsable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ public protocol CSVParsable {
}

extension CSVParsable {
static func buildCSV(@CSVBuilder build: () -> String) -> String { build() }
public static func buildCSV(@CSVBuilder build: () -> String) -> String { build() }
}
6 changes: 5 additions & 1 deletion Sources/FileCache/FileCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public class FileCache<T: JSONParsable & CSVParsable> {
case unknown
}

public init() {

}

public func loadFromFile(named fileName: String, format: FileFormat) -> Result<[T], FileError> {
do {
let url = try getDocumentsDirectory().appendingPathComponent(fileName)
Expand Down Expand Up @@ -71,7 +75,7 @@ public class FileCache<T: JSONParsable & CSVParsable> {
}

@discardableResult
public func saveToFile(named fileName: String, items: [T], format: FileFormat = .json) -> FileError? {
public func saveToFile(_ items: [T], named fileName: String, format: FileFormat = .json) -> FileError? {
do {
let url = try getDocumentsDirectory().appendingPathComponent(fileName)
switch format {
Expand Down
8 changes: 4 additions & 4 deletions Sources/FileCache/JSONParsing/JSONParsable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ public protocol JSONParsable {
static func parse(json: JSONDictionary) -> Self?
}

public extension JSONParsable {
static func buildJSON(@JSONBuilder build: () -> JSONDictionary) -> JSONDictionary { build() }
extension JSONParsable {
public static func buildJSON(@JSONBuilder build: () -> JSONDictionary) -> JSONDictionary { build() }

var jsonString: String? {
public var jsonString: String? {
guard let jsonData = try? JSONSerialization.data(withJSONObject: json) else {
DDLogError("Failed to serialize JSON data for \(self)")
return nil
Expand All @@ -35,7 +35,7 @@ public extension JSONParsable {
/// Converts a JSON string to an object.
/// - Parameter jsonString: JSON string.
/// - Returns: Returns an object created from a JSON string, or nil if the conversion failed.
static func from(jsonString: String) -> Self? {
public static func from(jsonString: String) -> Self? {
guard let jsonData = jsonString.data(using: .utf8) else {
DDLogError("Failed to convert string to data: \(jsonString)")
return nil
Expand Down

0 comments on commit 6432dfd

Please sign in to comment.