scala-faker


License

License

Categories

Categories

Scala Languages
GroupId

GroupId

com.andrewmccall.faker
ArtifactId

ArtifactId

scala-faker_2.11
Last Version

Last Version

0.0.5
Release Date

Release Date

Type

Type

jar
Description

Description

scala-faker
scala-faker
Project URL

Project URL

https://github.com/andrewmccall/scala-faker
Project Organization

Project Organization

com.andrewmccall.faker
Source Code Management

Source Code Management

https://github.com/andrewmccall/scala-faker

Download scala-faker_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/com.andrewmccall.faker/scala-faker_2.11/ -->
<dependency>
    <groupId>com.andrewmccall.faker</groupId>
    <artifactId>scala-faker_2.11</artifactId>
    <version>0.0.5</version>
</dependency>
// https://jarcasting.com/artifacts/com.andrewmccall.faker/scala-faker_2.11/
implementation 'com.andrewmccall.faker:scala-faker_2.11:0.0.5'
// https://jarcasting.com/artifacts/com.andrewmccall.faker/scala-faker_2.11/
implementation ("com.andrewmccall.faker:scala-faker_2.11:0.0.5")
'com.andrewmccall.faker:scala-faker_2.11:jar:0.0.5'
<dependency org="com.andrewmccall.faker" name="scala-faker_2.11" rev="0.0.5">
  <artifact name="scala-faker_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.andrewmccall.faker', module='scala-faker_2.11', version='0.0.5')
)
libraryDependencies += "com.andrewmccall.faker" % "scala-faker_2.11" % "0.0.5"
[com.andrewmccall.faker/scala-faker_2.11 "0.0.5"]

Dependencies

compile (8)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.12
org.yaml : snakeyaml jar 1.24
org.reflections : reflections jar 0.9.11
org.apache.logging.log4j : log4j-core jar 2.8.2
org.apache.logging.log4j : log4j-api jar 2.8.2
org.apache.logging.log4j : log4j-api-scala_2.11 jar 11.0
com.fasterxml.jackson.dataformat : jackson-dataformat-yaml jar 2.7.3
com.fasterxml.jackson.core : jackson-databind jar 2.5.4

test (3)

Group / Artifact Type Version
org.scalatest : scalatest_2.11 jar 3.0.6
org.mockito : mockito-scala_2.11 jar 1.4.1
org.mockito : mockito-scala-scalatest_2.11 jar 1.4.1

Project Modules

There are no modules declared in this project.

Scala Faker

Maven Central Download BuildStatus Codacy Badge Codacy Badge

An implementation fo the Ruby faker library in scala. The intial implementation is a direct port of the ruby code to scala, updates have tried to make it more scala like.

This code uses modified YAML files from the ruby faker project and implements all the methods supported there.

Usage

Using the faker is as simple as creating a new faker and passing in keys.

val faker = new Faker()
val someString = faker("name.name")

Keys in strings

{} is the standard notation for embedding a key.

val string = "Hi! My name is #{Name.name}"
val result = faker(string)

Configuration

Locales

A faker can be configured for a different locale, allowing different languages and formats of keys to be returned. eg. UK Addresses.

val config = new Config(locale="en-GB")
val faker = new Faker(config)

Keys that are not found in the selected locale are automatically looked up in the en locale.

Random implementation

The default random implementation uses a ThreadlocalRandom.current() to generate random numbers. This can be overriden if for example you need to provide a seed for reproducibility by setting another subclass of java.util.Random in the config.

val myRandom = new Random(1)
val config = new Config(random=myRandom)
val faker = new Faker(config) 

Adding additional keys

This section is a work in progress

Versions

Version
0.0.5
0.0.3