Swiftpack.co - Package - vadymmarkov/Fakery

Fakery logo CI Status Carthage Version License Platform

This is a Swift port of Ruby's Faker library that generates fake data.

Are you still bothered with meaningless randomly character strings? Just relax and leave this job to Fakery. It's useful in all the cases when you need to use some dummy data for testing, population of database during development, etc.

NOTE: Generated data is pretty realistic, supports a range of locales, but returned values are not guaranteed to be unique.

Table of Contents

Usage


let faker = Faker(locale: "nb-NO")

let firstName = faker.name.firstName()  //=> "Emilie"
let lastName = faker.name.lastName()    //=> "Hansen"
let city = faker.address.city()         //=> "Oslo"

Localization

Fakery is quite powerful when it comes to generation of locale-specific data. In Resources/Locales you can find JSON files for more than 20 locales, and, of course, it's not a limit. Feel free to contribute and add more!

The default locale is English. When you use one of the available generators and the corresponding key is not found in a JSON file for the currently selected locale Fakery will also check if it exists in "en.json" file.

Generators

Address


faker.address.city() //=> "Oslo"
faker.address.streetName() //=> "North Avenue"
faker.address.secondaryAddress() //=> "Apt. 123"
faker.address.streetAddress(includeSecondary: Bool) //=> "12 North Avenue"
faker.address.buildingNumber() //=> "123"
faker.address.postcode(stateAbbreviation: String) //=> "0884"
faker.address.timeZone() //=> "America/Los_Angeles"
faker.address.streetSuffix() //=> "Avenue"
faker.address.citySuffix() //=> "town"
faker.address.cityPrefix() //=> "North"
faker.address.stateAbbreviation() //=> "CA"
faker.address.state() //=> "California"
faker.address.county() //=> "Autauga County"
faker.address.country() //=> "United States of America"
faker.address.countryCode() //=> "US"
faker.address.latitude() //=> -58.17256227443719
faker.address.longitude() //=> -156.65548382095133
faker.address.coordinate() //=> CLLocationCoordinate2D(latitude: 40.97868, longitude: 29.09306)

App


faker.app.name() //=> "Namfix"
faker.app.version() //=> "0.1.1"
faker.app.author() //=> "Ida Adams"

Business


faker.business.creditCardNumber() //=> "1234-2121-1221-1211"
faker.business.creditCardType() //=> "visa"
faker.business.creditCardExpiryDate() //=> "2020-10-12"

Cat


faker.cat.name() //=> "Shadow"        
faker.cat.breed() //=> "British Semipi-longhair"
faker.cat.registry() //=> "American Cat Fanciers Association"

Commerce


faker.commerce.color() //=> "black"
faker.commerce.department(maximum: Int, fixedAmount: Bool) //=> "Music"
faker.commerce.productName() //=> "Awesome Wooden Hat"
faker.commerce.price() // 90.5

Company


faker.company.name() //=> "Adams Inc"       
faker.company.suffix() //=> "Inc"
faker.company.catchPhrase() //=> "Universal software"        
faker.company.bs() //=> "implement innovative methodologies"
faker.company.logo() // "http://pigment.github.io/fake-logos/logos/medium/color/1.png"

Zelda


faker.zelda.game() //=> "Ocarina of Time"   

Gender


faker.gender.type() //=> "Agender"
faker.gender.binaryType() //=> "Male"

Internet


faker.internet.username(separator: String?) //=> "ida4"       
faker.internet.domainName(alphaNumericOnly: Bool) //=> "example.com"        
faker.internet.domainWord(alphaNumericOnly: Bool) //=> "domainword"        
faker.internet.domainSuffix() //=> "com"
faker.internet.email() // => "ida4@some.info"
faker.internet.freeEmail() //=> "gmail.com"
faker.internet.safeEmail() //=> "adams@example.org"
faker.internet.password(minimumLength: Int, maximumLength: Int) //=> "e2dddhwd1g5qhvhgfi"
faker.internet.ipV4Address() //=> "24.29.18.175"
faker.internet.ipV6Address() //=> "ac5f:d696:3807:1d72:2eb5:4e81:7d2b:e1df"
faker.internet.url() //=> "http://example.com/ida4"
faker.internet.image() //=> "http://lorempixel.com/320/200"
faker.internet.templateImage() //=> "http://dummyimage.com/320x200/000000/ffffff"
faker.internet.hashtag() //=> "#art"

Lorem


faker.lorem.word() //=> "repellendus"         
faker.lorem.words(amount: Int) //=> ["dolores", "adipisci", "nesciunt"]      
faker.lorem.character() //=> "a"        
faker.lorem.characters(amount: Int) // Default = 255
faker.lorem.sentence(wordsAmount: Int) // Default = 4
faker.lorem.sentences(amount: Int) // Default = 3
faker.lorem.paragraph(sentencesAmount: Int) // Default = 3
faker.lorem.paragraphs(amount: Int) // Default = 3

Name


faker.name.name() //=> "Ida Adams"        
faker.name.firstName() //=> "Ida"
faker.name.lastName() //=> "Adams"
faker.name.prefix() //=> "Mrs."
faker.name.suffix() //=> "PhD"
faker.name.title() //=> "Lead"

Number


faker.number.randomBool() //=> true or false
faker.number.randomInt() //=> some Int between 0 and 1000
faker.number.randomInt(min: -100, max:50) //=> some Int between -100 and 50
faker.number.randomFloat() //=> some Float between 0 and 1000
faker.number.randomFloat(min: -10.4, max:50) //=> some Float between -10.4 and 50
faker.number.randomCGFloat() //=> some CGFloat between 0 and 1000
faker.number.randomCGFloat(min: 42.42, max:86) //=> some CGFloat between -42.42 and 86
faker.number.randomDouble() //=> some Double between 0 and 1000
faker.number.randomDouble(min: 0, max:1) //=> some Double between 0 and 1
faker.number.increasingUniqueId() //=> every call returns an unique int

Phone number


faker.phoneNumber.phoneNumber() //=> "1-333-333-3333"        
faker.phoneNumber.cellPhone() //=> "333-333-3333"
faker.phoneNumber.areaCode() //=> "201"
faker.phoneNumber.exchangeCode() //=> "201"
faker.phoneNumber.subscriberNumber() //=> "1234"
faker.phoneNumber.numberExtension(length: Int) // "123"

Team


faker.team.name() //=> "bats"         
faker.team.creature() //=> "Alabama bats"
faker.team.state() // => "Alabama"

Bank

faker.bank.name() //=> "ABN AMRO CORPORATE FINANCE LIMITED"         
faker.bank.swiftBic() //=> "AAFMGB21"
faker.bank.iban() // => "NL45BUNQ2209931378"
faker.bank.bban() //=> ABNA0136468471

Hobbit

faker.hobbit.character() //=> "Bilbo Baggins"         
faker.hobbit.thorinsCompany() //=> "Thorin Oakenshield"
faker.hobbit.quote() // => "Do you wish me a good morning, or mean that it is a good morning whether I want it or not; or that you feel good this morning; or that it is a morning to be good on?"
faker.hobbit.location() //=> "Bree"

Car

faker.car.brand() //=> "BMW"

Programming language

faker.programming_language.name() //=> "Elixir"         
faker.programming_language.creator() //=> "José Valim"         

Vehicle

faker.vehicle.manufacture() //=> "Volkswagen" 
faker.vehicle.make() //=> "BMW"
faker.vehicle.colors() //=> "Red"

Ham

faker.ham.name() //=> "Taylor Ham"         

House

faker.house.furniture() //=> "chair"
faker.house.room() //=> "living room" 

Installation

Fakery is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Fakery'

Contributing

Please see our playbook for guidelines on contributing.

Author

Vadym Markov, markov.vadym@gmail.com

License

Fakery is available under the MIT license. See the LICENSE file for more info.

Github

link
Stars: 1300

Dependencies

Used By

Total: 0

Releases

4.1.1 - 2019-07-25 15:46:08

Fix warnings https://github.com/vadymmarkov/Fakery/pull/124

4.1.0 - 2019-07-24 09:11:48

  • Move all generators into namespace Faker https://github.com/vadymmarkov/Fakery/pull/121
  • House generator https://github.com/vadymmarkov/Fakery/pull/122
  • Zelda generator https://github.com/vadymmarkov/Fakery/pull/119
  • Hobbit generator https://github.com/vadymmarkov/Fakery/pull/117
  • Cat generator https://github.com/vadymmarkov/Fakery/pull/116
  • Car brands generator https://github.com/vadymmarkov/Fakery/pull/115
  • Gender generator https://github.com/vadymmarkov/Fakery/pull/114
  • Vehicle generator https://github.com/vadymmarkov/Fakery/pull/113
  • Hams generator https://github.com/vadymmarkov/Fakery/pull/112
  • Programming language generator https://github.com/vadymmarkov/Fakery/pull/111

4.0.0 - Swift 5 - 2019-04-25 08:02:29

3.4.0 - 2018-09-14 08:51:49

  • Create pt-BR.json https://github.com/vadymmarkov/Fakery/pull/89
  • Update the project to recommended settings https://github.com/vadymmarkov/Fakery/pull/93
  • Add NL postcode https://github.com/vadymmarkov/Fakery/pull/96
  • Fix ipV6Address() bug https://github.com/vadymmarkov/Fakery/pull/100

3.3.0 - 2017-11-13 11:11:10

New address method for generating coordinate by @emrahgunduz https://github.com/vadymmarkov/Fakery/pull/88

3.2.1 - 2017-11-09 09:26:14

Fix swift 4 deprecations warnings https://github.com/vadymmarkov/Fakery/pull/87 by @hemangshah

3.2.0 - 2017-10-17 07:24:48

  • Add SwiftPackageManager support https://github.com/vadymmarkov/Fakery/pull/84
  • Look for the key in "en.json" if it's not found in the selected locale https://github.com/vadymmarkov/Fakery/pull/83
  • Use https for output links https://github.com/vadymmarkov/Fakery/pull/82

3.1.0 - 2017-10-12 14:43:44

Expose Bank class, add more specs by @dunyakirkali https://github.com/vadymmarkov/Fakery/pull/79

3.0.0 - Swift 4 - 2017-10-02 17:34:30

  • Migrate source code to Swift 4 https://github.com/vadymmarkov/Fakery/pull/76
  • Generate BBAN numbers (only NL) by @dunyakirkali https://github.com/vadymmarkov/Fakery/pull/77

2.1.0 - More features - 2017-09-21 18:52:27

  • Support lowest possible versions of macOS and tvOS https://github.com/vadymmarkov/Fakery/pull/60
  • Add tc locale https://github.com/vadymmarkov/Fakery/pull/62
  • Add hashtags https://github.com/vadymmarkov/Fakery/pull/65
  • tvOS & macOS Podspec Changes https://github.com/vadymmarkov/Fakery/pull/68
  • Bank names and IBAN numbers https://github.com/vadymmarkov/Fakery/pull/74

2.0.0 - Swift 3 - 2016-09-27 19:37:45

Swift 3 migration https://github.com/vadymmarkov/Fakery/pull/56

1.4.0 - Remove dependencies - 2016-09-27 08:25:17

https://github.com/vadymmarkov/Fakery/pull/55

1.3.2 - Fix podspec - 2016-09-24 10:23:43

1.3.1 - 2016-09-22 17:05:57

  • Add tvOS target for Carthage #52

1.3.0 - Improve French locales - 2016-06-30 16:46:06

Thanks @Appsido who made it happen! https://github.com/vadymmarkov/Fakery/pull/47 https://github.com/vadymmarkov/Fakery/pull/48

1.2.0 - Random numbers - 2016-04-21 22:16:16

  • Random numbers generator https://github.com/vadymmarkov/Fakery/pull/42 by @FGoessler
  • Improve fr locale by @ptsakyrellis

Thanks guys for making this great release!

1.1.2 - Company generator - 2016-02-09 23:08:58

  • Add the company generator (thanks, @bojan)

1.1.1 - Fix dependencies - 2016-01-28 18:19:27

Update dependencies

1.1.0 - Falsification of images - 2015-11-25 22:06:18

  • Add Carthage support + framework resources path (All the credits go to @diogoguimaraes :star2: )
  • Random image URL generation

1.0.0 - Fakery - 2015-09-20 13:22:47

This is a initial release, over this point releases will use http://semver.org/

0.5 - Swift 1.2 - 2015-09-20 13:18:33

Swift 1.2 release.