Skip to content

Commit

Permalink
Version 3.0 (#9)
Browse files Browse the repository at this point in the history
* Default the output to use only ASCII by default
* Add support for all functional interfaces in Java. 
* Cleanup formatting configuration and output formatting
* Update test/build dependencies

---------

Co-authored-by: Morten Haraldsen <[email protected]>
  • Loading branch information
ethlo and Morten Haraldsen authored Dec 5, 2024
1 parent 475eb3c commit cb4093b
Show file tree
Hide file tree
Showing 12 changed files with 1,189 additions and 254 deletions.
38 changes: 21 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<artifactId>chronograph</artifactId>
<name>Chronograph</name>
<description>Easy-to-use stopwatch for task performance statistics</description>
<version>2.0.0</version>
<version>3.0.0</version>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
Expand All @@ -26,7 +26,7 @@
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<version>3.13.0</version>
<configuration>
<source>17</source>
<target>17</target>
Expand All @@ -36,7 +36,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<version>0.8.12</version>
<executions>
<execution>
<id>prepare-agent</id>
Expand All @@ -54,7 +54,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<version>3.5.0</version>
<configuration>
<excludes>
<exclude>**/*BenchmarkTest.java</exclude>
Expand All @@ -64,7 +64,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -77,7 +77,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.1</version>
<version>3.6.3</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand All @@ -93,12 +93,12 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.8.1</version>
<version>2.16.2</version>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<version>1.6.14</version>
<extensions>true</extensions>
<configuration>
<serverId>sonatype-nexus-staging</serverId>
Expand All @@ -109,7 +109,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<version>3.2.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand All @@ -126,7 +126,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>2.0.0</version>
<version>2.2.0</version>
<configuration>
<verbose>false</verbose>
</configuration>
Expand Down Expand Up @@ -165,7 +165,7 @@
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.12</version>
<version>3.5.3</version>
</extension>
</extensions>
</build>
Expand All @@ -177,7 +177,7 @@
</repository>
</distributionManagement>
<scm>
<url>https://github.com:ethlo/chronograph</url>
<url>https://github.com/ethlo/chronograph</url>
<connection>scm:git:[email protected]:ethlo/chronograph.git</connection>
<developerConnection>scm:git:[email protected]:ethlo/chronograph.git</developerConnection>
</scm>
Expand All @@ -189,21 +189,25 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.0</version>
<version>5.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.14.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.8.0-beta4</version>
<version>2.0.12</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.23.1</version>
<version>3.25.3</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
88 changes: 53 additions & 35 deletions src/main/java/com/ethlo/ascii/TableTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,25 @@ public class TableTheme
{
// Inspiration: https://www.compart.com/en/unicode/search?q=Box+Drawings#characters

public static final TableTheme DEFAULT = TableTheme.builder().build();

public static final TableTheme TSV = TableTheme.builder()
.leftTop("")
.rightTop("")
.bottomCross("")
.topCross("")
.rightBottom("")
.leftBottom("")
.verticalSeparator("")
.horizontalSeparator("\t")
public static final TableTheme ASCII = TableTheme.builder().name("ASCII").build();

public static final TableTheme SINGLE = TableTheme.builder()
.name("Single")
.cross("┼")
.rightCross("┤")
.leftCross("├")
.topCross("┬")
.bottomCross("┴")
.leftTop("┌")
.rightTop("┐")
.leftBottom("└")
.rightBottom("┘")
.verticalSeparator("─")
.horizontalSeparator("│")
.build();

public static final TableTheme DOUBLE = TableTheme.builder()
.name("Double")
.cross("╬")
.rightCross("╣")
.leftCross("╠")
Expand All @@ -50,37 +55,35 @@ public class TableTheme
.verticalSeparator("═")
.horizontalSeparator("║")
.build();

public static final TableTheme ROUNDED = DEFAULT.begin()
.leftTop("╭")
.rightTop("╮")
.leftBottom("╰")
.rightBottom("╯")
.build();

public static final TableTheme RED_HERRING = TableTheme.builder()
.name("Red Herring")
.stringColor(AnsiColor.BRIGHT_WHITE)
.numericColor(AnsiColor.GREEN)
.verticalSpacerColor(AnsiColor.RED)
.horizontalSpacerColor(AnsiColor.RED)
.cellBackground(AnsiBackgroundColor.BLACK)
.build();

public static final TableTheme MINIMAL = TableTheme.builder()
.name("Minimal")
.stringColor(AnsiColor.GRAY)
.numericColor(AnsiColor.GREEN)
.horizontalSeparator(" ")
.verticalSpacerColor(AnsiColor.GRAY)
.horizontalSpacerColor(AnsiColor.GRAY)
.cellBackground(AnsiBackgroundColor.BLACK)
.build();

public static final TableTheme COMPACT = TableTheme.builder()
.name("Compact")
.verticalSeparator("")
.horizontalSeparator("")
.padding(" ")
.build();

public static final TableTheme DEFAULT = ASCII;
public static final TableTheme ROUNDED = SINGLE.begin()
.name("Rounded")
.leftTop("╭")
.rightTop("╮")
.leftBottom("╰")
.rightBottom("╯")
.build();
private final AnsiColor stringColor;
private final AnsiColor numericColor;
private final AnsiColor horizontalSpacerColor;
Expand All @@ -99,9 +102,11 @@ public class TableTheme
private final String rightBottom;
private final String topCross;
private final String bottomCross;
private final String name;

private TableTheme(Builder builder)
{
this.name = builder.name;
this.stringColor = builder.stringColor;
this.numericColor = builder.numericColor;
this.horizontalSpacerColor = builder.horizontalSpacerColor;
Expand Down Expand Up @@ -129,6 +134,7 @@ public static Builder builder()
public Builder begin()
{
final Builder builder = new Builder();
builder.name = this.name;
builder.stringColor = this.stringColor;
builder.numericColor = this.numericColor;
builder.horizontalSpacerColor = this.horizontalSpacerColor;
Expand Down Expand Up @@ -234,25 +240,31 @@ public String getRightBottom()
return rightBottom;
}

public String getName()
{
return name;
}

public static final class Builder
{
public String topCross = "";
public String bottomCross = "";
public String topCross = "+";
public String bottomCross = "+";
private AnsiColor stringColor = AnsiColor.NONE;
private AnsiColor numericColor = AnsiColor.NONE;
private AnsiColor horizontalSpacerColor = AnsiColor.NONE;
private AnsiColor verticalSpacerColor = AnsiColor.NONE;
private AnsiBackgroundColor cellBackground = AnsiBackgroundColor.NONE;
private String horizontalSeparator = "";
private String verticalSeparator = "";
private String horizontalSeparator = "|";
private String verticalSeparator = "-";
private String padding = " ";
private String cross = "┼";
private String leftCross = "├";
private String rightCross = "┤";
private String leftTop = "┌";
private String rightTop = "┐";
private String leftBottom = "└";
private String rightBottom = "┘";
private String cross = "+";
private String leftCross = "+";
private String rightCross = "+";
private String leftTop = "+";
private String rightTop = "+";
private String leftBottom = "+";
private String rightBottom = "+";
private String name;

private Builder()
{
Expand Down Expand Up @@ -364,5 +376,11 @@ public TableTheme build()
{
return new TableTheme(this);
}

public Builder name(String name)
{
this.name = name;
return this;
}
}
}
Loading

0 comments on commit cb4093b

Please sign in to comment.