{"id":24277666,"url":"https://github.com/nikdon/scala-sample","last_synced_at":"2025-03-05T11:23:02.040Z","repository":{"id":80099543,"uuid":"76741572","full_name":"nikdon/scala-sample","owner":"nikdon","description":"Random object generation with shapeless","archived":false,"fork":false,"pushed_at":"2017-02-14T10:26:46.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-16T00:29:05.414Z","etag":null,"topics":["generic-programming","scala","shapeless","test-data"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nikdon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-17T19:02:16.000Z","updated_at":"2016-12-28T21:56:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"a5c0076b-05e3-4873-9fe9-a1ab880dada2","html_url":"https://github.com/nikdon/scala-sample","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikdon%2Fscala-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikdon%2Fscala-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikdon%2Fscala-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikdon%2Fscala-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nikdon","download_url":"https://codeload.github.com/nikdon/scala-sample/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242015758,"owners_count":20058084,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["generic-programming","scala","shapeless","test-data"],"created_at":"2025-01-15T23:58:31.924Z","updated_at":"2025-03-05T11:23:02.027Z","avatar_url":"https://github.com/nikdon.png","language":"Scala","readme":"# scala-sample\n\n[![Build Status](https://travis-ci.org/nikdon/scala-sample.svg?branch=master)](https://travis-ci.org/nikdon/scala-sample)\n[![codecov](https://codecov.io/gh/nikdon/scala-sample/branch/master/graph/badge.svg)](https://codecov.io/gh/nikdon/scala-sample)\n[![](https://jitpack.io/v/nikdon/scala-sample.svg)](https://jitpack.io/#nikdon/scala-sample)\n\n\n**scala-sample** is code snippet for random object generation from [**shapeless guide**](https://github.com/underscoreio/shapeless-guide)\nas a library that can be used in any scala project of version 2.11.+ (version of scala-sample \"1.0.0\") and 2.12.+ (see below)\n\n## Table of contents\n\n1. [Quick start](#quick-start)\n2. [Usage](#usage)\n3. [License](#license)\n\n## Quick start\n\nTo use **scala-sample** add following to build file:\n\n```scala\nresolvers += \"jitpack\" at \"https://jitpack.io\"\nlibraryDependencies += \"com.github.nikdon\" % \"scala-sample\" % \"2.0.0\"\n```\n\n## Usage\n\n```scala\nimport com.github.nikdon.sample.Sample\n\nimport java.time.Instant\n\nsealed trait Foo\ncase class Fiz(fiz: String) extends Foo\ncase class Buz(buz: String) extends Foo\n\ncase class SomeEvent(happenedAt: Instant)\n\n\nobject Test extends App {\n  val foo = Sample[Foo].get  // returns an instance of type Foo (Fiz or Buz)\n\n  val nFoo = Sample[Foo].getN(2) // returns a List[Foo] of size 2\n  \n  // in some cases it is necessary to provide an implementation of `Sample` \n  implicit val instantSample = new Sample[Instant] {\n    override def get: Instant = Instant.now\n  }\n  \n  val event = Sample[SomeEvent].get // returns a SomeEvent\n  \n  // it works with Option[_] and Either[_, _]\n  val someEvent = Sample[Option[SomeEvent]].get\n  val eitherStringOrEvent = Sample[Either[String, SomeEvent]].get\n   \n  println(s\"foo                 = $foo\")\n  println(s\"nFoo                = $nFoo\")\n  println(s\"event               = $event\")    \n  println(s\"someEvent           = $someEvent\")    \n  println(s\"eitherStringOrEvent = $eitherStringOrEvent\")    \n}\n```\n\n## License\n\nPlease refer to [**shapeless guide**](https://github.com/underscoreio/shapeless-guide)'s license.\n\n[![Analytics](https://ga-beacon.appspot.com/UA-91956314-1/scala-sample/readme?pixel)](https://github.com/igrigorik/ga-beacon)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikdon%2Fscala-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikdon%2Fscala-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikdon%2Fscala-sample/lists"}