diff --git a/Package.swift b/Package.swift index 13917a8..e300da4 100644 --- a/Package.swift +++ b/Package.swift @@ -1,5 +1,20 @@ +// swift-tools-version:5.9 + import PackageDescription let package = Package( - name: "Phrase" + name: "Phrase", + products: [ + .library( + name: "Phrase", + targets: ["Phrase"]), + ], + targets: [ + .target( + name: "Phrase", + dependencies: []), + .testTarget( + name: "PhraseTests", + dependencies: ["Phrase"]), + ] ) diff --git a/Phrase.podspec b/Phrase.podspec index 4561f21..bf3d10b 100755 --- a/Phrase.podspec +++ b/Phrase.podspec @@ -1,13 +1,12 @@ Pod::Spec.new do |spec| spec.name = 'Phrase' - spec.version = '2.0.0' + spec.version = '3.0.0' spec.license = { :type => 'Apache License, Version 2.0' } spec.homepage = 'https://github.com/codyrobb/Phrase' spec.authors = { 'Cody Robertson' => 'codyrobertsonn@gmail.com' } spec.summary = 'A Swift templating library.' - spec.source = { :git => 'https://github.com/codyrobb/Phrase.git', :tag => '2.0.0' } + spec.source = { :git => 'https://github.com/codyrobb/Phrase.git', :tag => '3.0.0' } spec.source_files = 'Sources/*' - spec.ios.deployment_target = '9.0' - spec.osx.deployment_target = '10.10' + spec.ios.deployment_target = '14.0' end diff --git a/Sources/Phrase.swift b/Sources/Phrase.swift index d73ca4b..daf0958 100644 --- a/Sources/Phrase.swift +++ b/Sources/Phrase.swift @@ -8,21 +8,16 @@ import Foundation - final public class Phrase { // MARK: - // MARK: Properties - /** - The template we will attempt to replace tokens of. - */ + /// The template we will attempt to replace tokens of. private let template: String - /** - The set of token replacements to be replaced in the template. - */ - private var replacements: [String: String] = [:] + /// The set of token replacements to be replaced in the template. + private var replacements: [String : String] = [:] // MARK: - // MARK: Initialization @@ -35,22 +30,22 @@ final public class Phrase { // MARK: Public /** - Adds a record to replace the tokenized key with the given value in the template. - - - Parameters: - - key: The key you want to replace. - - value: The value to replace the key with. - - Returns: Returns itself for easy chaining. + * Adds a record to replace the tokenized key with the given value in the template. + * + * - Parameters: + * - key: The key you want to replace. + * - value: The value to replace the key with. */ + @discardableResult public func put(key: String, value: CustomStringConvertible) -> Phrase { replacements[key] = value.description return self } /** - Returns a formatted string by attempting to replace all tokens with their respective values. - - - Returns: A formatted string with all current replacements. + * Returns a formatted string by attempting to replace all tokens with their respective values. + * + * - Returns: A formatted string with all current replacements. */ public func format() -> String { var formatted = template @@ -66,10 +61,10 @@ final public class Phrase { // MARK: Private /** - Tokenizes the given key. - - - Parameter key: The key you want to tokenize. - - Returns: A tokenized version of the key. + * Tokenizes the given key. + * + * - Parameter key: The key you want to tokenize. + * - Returns: A tokenized version of the key. */ private func tokenize(key: String) -> String { return "{" + key + "}"