NamingConventions is a library amied to help converting Name/IDs following different Naming Conventinos to each other. for example you might have a string with a given or even unknown naming-convention, and you want it to be converted to say a snake-cased-string.
To use the code, you will just create an instance of ConventionConverter class, call the method: autoConvert(from:<name-id-string>,to:<destination-convention>). and the result will be your string following the destination naming convention.
let converter = ConventionConverter()
let convention = NamingConventions.SnakeCase
let src = "MyFieldName"
let result = converter.autoConvert(from: src, to: convention)
print(src + " -> " + result)
output:
MyFieldName -> my-field-name
NamingConvention:
You can get an object of a naming convention from the class: NamingConventions. you also can create one using its initializer (constructor) like:
let myConvention = NamingConvention(starter: "_", firstParticle: ParticleCase.Lower, otherParticles: ParticleCase.Pretty, separator: "")
This project does not have any dependencies (except for foundation!)
- Cocoapods
NamingConventions is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'NamingConventions'
- Carthage
To get the latest version of library using Carthage, you can add following line to your Cartfile.
github "Acidmanic/SwiftNamingConventions"
NamingConventions is available under the MIT license. See the LICENSE file for more info.
Thanks & Good luck 👍 Mani