Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A library for generating fake data written in scala.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 project
Octocat-spinner-32 src
Octocat-spinner-32 .gitignore
Octocat-spinner-32 README.markdown
Octocat-spinner-32 version.sbt
README.markdown

scala-faker

scala-faker is a library written in Scala which generates fake data such as names, addresses, and phone numbers. It is a Scala port of the famous Ruby library faker. It actually uses the same data for generating.

Notice: This README contains information which might only be valid for the latest snapshot version. See tags to find the README targeting your version.

This release of scala-faker is build against Scala 2.8.0, 2.8.1, 2.8.2, 2.9.0, 2.9.0-1 and 2.9.1.

scala-faker only depends on snakeyaml for reading the original faker yaml files. The tests are written with scalatest.

Usage

This section will give you a short introduction on how to get started with scala-faker.

Code

So how do I use it? Let's see ...

import faker._ // That's all you need!

case class User(name: String, username: String, email: String)

val name = Name.name
val user = User(name, Internet.user_name(name), Internet.free_email(name))
// User(Kimi Hauke,kimihauke,haukekimi@hotmail.com)

Pretty easy, right?

Localization

By default scala-faker tries you systems locale for generating fake data. If there isn't any localization for it (right now there are files for: de-ch, de, en-gb, en-us, en, nl) it will fall back to en. The locale can be changed any time with Faker.locale(newLocale).

import faker._

// changing Language to german
Faker.locale("de")

Add dependency

Adding scala-faker as dependency to your project is really simple. Just add

sbt

resolvers += "justwrote" at "http://repo.justwrote.it/releases/"

libraryDependencies += "it.justwrote" %% "scala-faker" % "0.1"

Maven

<repository>
    <id>justwrote</id>
    <url>http://repo.justwrote.it/releases/</url>
</repository>
...
<dependency>
    <groupId>it.justwrote</groupId>
    <artifactId>scala-faker_2.9.1</artifactId>
    <version>0.1</version>
</dependency>

where 2.9.1 is you Scala version.

Credits

This library uses the locales data from the ruby faker library.

Contribution policy

Contributions via GitHub pull requests are gladly accepted from their original author. Along with any pull requests, please state that the contribution is your original work and that you license the work to the project under the project's open source license. Whether or not you state this explicitly, by submitting any copyrighted material via pull request, email, or other means you agree to license the material under the project's open source license and warrant that you have the legal authority to do so.

License

scala-faker is licensed under the Apache 2.0 License.

Something went wrong with that request. Please try again.