spy

Pretty printed human readable String inspection of Scala objects

License

License

GroupId

GroupId

com.gu
ArtifactId

ArtifactId

spy_2.13
Last Version

Last Version

0.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

spy
Pretty printed human readable String inspection of Scala objects
Project URL

Project URL

https://github.com/guardian/spy
Project Organization

Project Organization

The Guardian
Source Code Management

Source Code Management

https://github.com/guardian/spy

Download spy_2.13

How to add to project

<!-- https://jarcasting.com/artifacts/com.gu/spy_2.13/ -->
<dependency>
    <groupId>com.gu</groupId>
    <artifactId>spy_2.13</artifactId>
    <version>0.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.gu/spy_2.13/
implementation 'com.gu:spy_2.13:0.1.1'
// https://jarcasting.com/artifacts/com.gu/spy_2.13/
implementation ("com.gu:spy_2.13:0.1.1")
'com.gu:spy_2.13:jar:0.1.1'
<dependency org="com.gu" name="spy_2.13" rev="0.1.1">
  <artifact name="spy_2.13" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.gu', module='spy_2.13', version='0.1.1')
)
libraryDependencies += "com.gu" % "spy_2.13" % "0.1.1"
[com.gu/spy_2.13 "0.1.1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.13.1

test (1)

Group / Artifact Type Version
org.scalameta : munit_2.13 jar 0.7.2

Project Modules

There are no modules declared in this project.

spy Maven Central

Library for Scala 2.13+ projects for pretty printing case classes with field names in hierarchical tree format. Useful for debugging purposes as it gives human readable representation of case classes. Provides .spy extension method for any object.

User guide

Works only with Scala 2.13+

libraryDependencies += "com.gu" %% "spy" % "x.x.x"

Example

import com.gu.spy._
case class Address(street: String, city: String, planet: String, country: String)
case class User(name: String, age: Int, address: Address)
val user = User("Jean-Luc Picard", 79, Address("Starfleet", "San Francisco", "Earth", "United Federation of Planets"))
println(user.spy)

where println(user.spy) outputs

User
  name: Jean-Luc Picard
  age: 79
  address: Address
    street: Starfleet
    city: San Francisco
    planet: Earth
    country: United Federation of Planets

as opposed to usual println(user) output

User(Jean-Luc Picard,79,Address(Starfleet,San Francisco,Earth,United Federation of Planets))

Credits

com.gu

The Guardian

The source code of the world's leading liberal voice

Versions

Version
0.1.1
0.1.0