Code Monkey home page Code Monkey logo

guitar's Introduction

Guitar

A Cross-Platform String Library Written in Swift.

BuddyBuild Platform Documentation

CocoaPods Carthage Compatible SwiftPM Compatible CocoaPods CocoaPods

About

This library seeks to add common string manipulation functions that are needed in both mobile and server-side development, but are missing in Swift's Foundation library.

The full documentation can be found at http://www.sabintsev.com/Guitar/.

Project Status

  • Release Stage: Alpha (until v0.1.0)
  • Development Status: Active Development (as of March 1, 2017)
  • Contributions are highly encouraged.

Roadmap

Functions

  • Boolean Functions (isAlpha, isNumeric, isUppercase, etc.)
  • Case Functions (camelCased, pascalCased, kebabCased, etc.)
  • Character Functions (first, length, reverse, etc.)
  • Latinization Functions
  • HTML Manipulation Functions
  • Padding Functions (padLeft, padRight, pad)
  • Regular Expressions / Regex (Pure Swift Implementation)
  • Trimming Functions (trimLeft, trimRight, prefixed, etc.)

Documentation

Dependency Management

  • Carthage Support
  • CocoaPods Support
  • Swift Package Manager

Testing

  • Continuous Integration with Buddy Build
  • SwiftLint Integration
  • Unit Tests

Installation Instructions

CocoaPods

pod 'Guitar'

Carthage

github "ArtSabintsev/Guitar"

Swift Package Manager

.Package(url: "https://github.com/ArtSabintsev/Guitar.git")

Implemented Functions

Boolean Operations

isAlpha()

let string = "HelloWorld"
string.isAlpha() // True

let string = "Hell0World"
string.isAlpha() // False

isAlphanumeric()

let string = "HelloWorld"
string.isAlphanumeric() // True

let string = "Hell0World"
string.isAlphanumeric() // True

let string = "Hell0 World"
string.isAlphanumeric() // False

isCapitalized()

let string = "Hello World"
string.isCapitalized() // True

let string = "hello World"
string.isCapitalized() // False

let string = "Hello-World"
string.isCapitalized() // True

isDecapitalized()

let string = "hello World"
string.isDecapitalized() // True

let string = "Hello World"
string.isDecapitalized() // False

let string = "hello-World"
string.isDecapitalized() // True

isLowercased()

// Note, Swift treats non-alphabetical characters as Uppercased.

let string = "helloworld"
string.isLowercased() // True

let string = "hello world"
string.isLowercased() // False

let string = "hello-world"
string.isLowercased() // False

isNumeric()

let string = "73110"
string.isNumeric() // True

let string = "73110 1337"
string.isNumeric() // False

let string = "73110World"
string.isNumeric() // False

isUpppercased()

// Note, Swift treats non-alphabetical characters as Uppercased.

let string = "HELLOWORLD"
string.isUpppercased() // True

let string = "HELLO WORLD"
string.isUpppercased() // True

let string = "HELLO-W0RLD"
string.isUpppercased() // True

let string = "HeLLoW0RLD"
string.isUpppercased() // False

Case Operations

camelCased()

let string = "Hello World"
string.camelCased() // "helloWorld"

let string = "hello_world"
string.camelCased() // "helloWorld"

decapitalized()

// Implementation is currently broken.

kebabCased()

let string = "Hello World"
string.kebabCased() // "-Hello-World-"

let string = "hello_world"
string.kebabCased() // "-hello-world-"

pascalCased()

let string = "Hello World"
string.pascalCased() // "HelloWorld"

let string = "hello_world"
string.pascalCased() // "HelloWorld"

slugCased()

let string = "Hello World"
string.slugCased() // "Hello-World"

snakeCased()

let string = "Hello World"
string.snakeCased() // "Hello_World"

swapCased()

let string = "Hello World"
string.swapCased() // "hELLO wORLD"

Character Operations

first()

let string = "Hello World"
string.first() // "H"

last()

let string = "Hello World"
string.last() // "d"

length()

let string = "Hello World"
string.length() // "11"

reversed()

let string = "Hello World"
string.reversed() // "dlroW olleH"

Padding Operations

padLeft()

let string = "Hello World" // 11 Characters
string.padLeft(length: 15) // "    Hello World"

let string = "Hello World" // 11 Characters
string.padLeft(length: 15, withToken: "*") // "****Hello World"

let string = "Hello World" // 11 Characters
string.padLeft(length: 5) // Returns the original string, "Hello World"

padRight()

let string = "Hello World" // 11 Characters
string.padRight(length: 15) // "Hello World    "

let string = "Hello World" // 11 Characters
string.padRight(length: 15, withToken: "*") // "Hello World****"

let string = "Hello World" // 11 Characters
string.padRight(length: 5) // Returns the original string, "Hello World"

pad()

let string = "Hello World" // 11 Characters
string.pad(length: 15) // "  Hello World  "

let string = "Hello World" // 11 Characters
string.pad(length: 5) // Returns the original string, "Hello World"

let string = "Hello World" // 11 Characters
string.pad(length: 15, withToken: "*") // "**Hello World**"

/* Note: If the difference between the final length
 and number of characters in the original string is odd,
 the string is padded extra on the right side.
 */
let string = "Hello World" // 11 Characters
string.pad(length: 16) // "  Hello World   "

let string = "Hello World" // 11 Characters
string.pad(length: 16) // "**Hello World***"

Trimming Operations

prefixed()

let string = "Hello World"
string.prefixed(length: 7) // "Hello W"

suffixed()

let string = "Hello World"
string.suffixed(length: 7) // "o World"

trimLeft()

let string = "Hello World"
string.trimLeft(length: 7) // "orld"

trimRight()

let string = "Hello World"
string.trimRight(length: 7) // "Hell"

truncated()

let string = "Hello World"
string.truncated(length: 7) // "Hell..." (Appends an ellipsis, ..., to the end of the string.)

Inspiration

This project was inspired by Voca.

Created and maintained by

Arthur Ariel Sabintsev

guitar's People

Contributors

artsabintsev avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.