Skip to content
Fake data generator
Scala
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cats-effect/src/main/scala/phony/cats/effect Separate RandomUtility and Locale Jul 12, 2019
core/src Separate RandomUtility and Locale Jul 12, 2019
project Enable scalac flags Jul 7, 2019
.gitignore Change the strcuture (#6) Jun 27, 2019
.scalafmt.conf Init commit Feb 9, 2019
.travis.yml Enable code coverage Jul 4, 2019
LICENSE Change License Jul 7, 2019
README.md Update Version Jul 12, 2019
build.sbt Update Version Jul 12, 2019
version.sbt Update Version Jul 12, 2019

README.md

Phony

Phony is fake data generate with cats library.

Build Status codecov

Quick Start

To use Phony in an existing SBT project with Scala 2.11 and 2.12, add the following dependency to your build.sbt:

resolvers += "phony" at "https://dl.bintray.com/meskin/phony/"

libraryDependencies += "com.github.alirezameskin" %% "phony-core" % "0.3.1"

Examples

  import phony.Phony
  import scala.util.Try
  import phony.instances.try_.languages.ENGLISH
  import phony.instances.try_._

  val bio = Phony[Try].lorem.text
  println(bio)
  import phony.Phony
  import phony.instances.either.languages.ENGLISH
  import phony.instances.either._

  type EitherA[A] = Either[Throwable, A]
  val bio = Phony[EitherA].lorem.text
  println(bio)

Using with cats-effect

resolvers += "phony" at "https://dl.bintray.com/meskin/phony/"

libraryDependencies += "com.github.alirezameskin" %% "phony-cats-effect" % "0.3.0-snapshot"
  import cats.effect.IO
  import phony.Phony
  import phony.cats.effect.instances.io.languages.ENGLISH
  import phony.cats.effect.instances.io._

  val bio = Phony[IO].lorem.text
  println(bio.unsafeRunSync())

Using with fs2

  import cats.effect.IO
  import fs2._
  import phony.Phony
  import phony.cats.effect.instances.io.languages.ENGLISH
  import phony.cats.effect.instances.io._

  case class Contact(firstName :String, lastName : String, age:Int)

  val contact = for {
    firstName <- Phony[IO].name.firstName
    lastName  <- Phony[IO].name.lastName
    age       <- Phony[IO].alphanumeric.number(18, 68)
  } yield Contact(firstName, lastName, age)

  val stream = Stream.eval(contact)
  stream.repeat.take(10).map(println).compile.drain.unsafeRunSync

Generators

Alphanumeric

  def char: F[Char]
  def boolean: F[Boolean]
  def float: F[Float]
  def number: F[Int]
  def number(max: Int)
  def number(min: Int, max: Int): F[Int]
  def custom(format: String) //format replace # with random number and replace ? with random character
  def hash: F[String]
  def hash(length: Int): F[String]

Calendar

  def year: F[Int]
  def day: F[String]
  def month: F[String]
  def time24h: F[String]
  def time12h: F[String]
  def date: F[Date]
  def date(format: String = "yyyy-MM-dd"): F[Date]
  def iso8601:F[String]
  def timezone: F[String]

Contact

  def firstName: F[String]
  def lastName: F[String]
  def prefix: F[String]
  def suffix: F[String]
  def fullName: F[String]
  def fullName(withPrefix: Boolean = false, withSuffix: Boolean = false): F[String]
  def username: F[String]
  def phone: F[String]
  def cellPhone: F[String]

Internet

  def uuid: F[String]
  def email: F[String]
  def password: F[String]
  def domain: F[String]
  def hostname: F[String]
  def protocol: F[String]
  def url: F[String]
  def ip: F[String]
  def ipv6: F[String]
  def hashtag: F[String]

Lorem

  def word: F[String]
  def words: F[List[String]]
  def words(length: Int): F[List[String]]
  def sentence: F[String]
  def text: F[String]
  def sentence(size: Int): F[String]
  def text(lines: Int): F[String]

Location

  def latitude: F[String]
  def longitude: F[String]
  def country: F[phony.data.Country]
  def countryName: F[String]
  def countryCode: F[String]
  def postalCode: F[String]
You can’t perform that action at this time.