("runJava") {
group = "application"
mainClass.set("com.example.ReadingTimeSample")
classpath = sourceSets.main.get().runtimeClasspath
- args = listOf("${project.projectDir}/example.html")
}
}
diff --git a/examples/gradle/example.html b/examples/gradle/example.html
new file mode 100644
index 0000000..799fca4
--- /dev/null
+++ b/examples/gradle/example.html
@@ -0,0 +1,127 @@
+HTML Ipsum Presents
+
+Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
+ Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas
+ semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien
+ ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae
, ornare sit amet, wisi.
+ Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis.
+
+
+ - Definition list
+ - Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
+ aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
+ commodo consequat.
+ - Lorem ipsum dolor sit amet
+ - Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
+ aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
+ commodo consequat.
+
+
+Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam,
+ feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies
+ mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat
+ wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros
+ ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis.
+ Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam
+ erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus
+
+Header Level 2
+
+
+ - Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
+ - Aliquam tincidunt mauris eu risus.
+ 
+
+
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet
+ congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus
+ est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.
+
+Header Level 3
+
+
+ - Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
+ - Aliquam tincidunt mauris eu risus.
+ 
+
+
+Header Level 4
+
+
+ - Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
+ - Aliquam tincidunt mauris eu risus.
+ 
+
+
+Header Level 5
+
+
+ - Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
+ - Aliquam tincidunt mauris eu risus.
+ 
+
+
+Header Level 6
+
+
+ - Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
+ - Aliquam tincidunt mauris eu risus.
+ 
+
+
+Header Level 6
+
+
+ - Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
+ - Aliquam tincidunt mauris eu risus.
+ 
+
+
+Header Level 6
+
+
+ - Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
+ - Aliquam tincidunt mauris eu risus.
+ 
+
+
+Header Level 6
+
+
+ - Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
+ - Aliquam tincidunt mauris eu risus.
+ 
+
+
+Header Level 6
+
+
+ - Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
+ - Aliquam tincidunt mauris eu risus.
+ 
+
+
+Header Level 6
+
+
+ - Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
+ - Aliquam tincidunt mauris eu risus.
+ 
+
+
+Header Level 6
+
+
+ - Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
+ - Aliquam tincidunt mauris eu risus.
+ 
+
+
+
+#header h1 a {
+ display: block;
+ width: 300px;
+ height: 80px;
+}
+
diff --git a/examples/gradle/wrapper/gradle-wrapper.jar b/examples/gradle/gradle/wrapper/gradle-wrapper.jar
similarity index 100%
rename from examples/gradle/wrapper/gradle-wrapper.jar
rename to examples/gradle/gradle/wrapper/gradle-wrapper.jar
diff --git a/examples/gradle/wrapper/gradle-wrapper.properties b/examples/gradle/gradle/wrapper/gradle-wrapper.properties
similarity index 100%
rename from examples/gradle/wrapper/gradle-wrapper.properties
rename to examples/gradle/gradle/wrapper/gradle-wrapper.properties
diff --git a/examples/gradlew b/examples/gradle/gradlew
similarity index 100%
rename from examples/gradlew
rename to examples/gradle/gradlew
diff --git a/examples/gradlew.bat b/examples/gradle/gradlew.bat
similarity index 100%
rename from examples/gradlew.bat
rename to examples/gradle/gradlew.bat
diff --git a/examples/settings.gradle.kts b/examples/gradle/settings.gradle.kts
similarity index 100%
rename from examples/settings.gradle.kts
rename to examples/gradle/settings.gradle.kts
diff --git a/examples/gradle/src/main/java/com/example/ReadingTimeSample.java b/examples/gradle/src/main/java/com/example/ReadingTimeSample.java
new file mode 100644
index 0000000..faaf6a2
--- /dev/null
+++ b/examples/gradle/src/main/java/com/example/ReadingTimeSample.java
@@ -0,0 +1,28 @@
+package com.example;
+
+import net.thauvin.erik.readingtime.ReadingTime;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+public class ReadingTimeSample {
+ public static void main(String[] args) {
+ if (args.length >= 1) {
+ final Path text = Path.of(args[0]);
+ try {
+ final ReadingTime rt = new ReadingTime(Files.readString(text));
+ rt.setPostfix("minute to read");
+ rt.setPlural("minutes to read");
+
+ System.out.println("It will take " + rt.calcReadingTime() + ' ' + ReadingTime.wordCount(rt.getText())
+ + " words and " + ReadingTime.imgCount(rt.getText()) + " images at " + rt.getWpm()
+ + " words per minute.");
+ } catch (IOException e) {
+ System.err.println("The file could not be read or found.");
+ }
+ } else {
+ System.err.println("Please specify a file as an argument.");
+ }
+ }
+}
diff --git a/examples/gradle/src/main/kotlin/com/example/ReadingTimeExample.kt b/examples/gradle/src/main/kotlin/com/example/ReadingTimeExample.kt
new file mode 100644
index 0000000..8563bc6
--- /dev/null
+++ b/examples/gradle/src/main/kotlin/com/example/ReadingTimeExample.kt
@@ -0,0 +1,25 @@
+package com.example
+
+import net.thauvin.erik.readingtime.ReadingTime
+import java.io.File
+
+fun main(args: Array) {
+ if (args.isNotEmpty()) {
+ with(File(args[0])) {
+ if (exists() && canRead()) {
+ val rt = ReadingTime(readText())
+ rt.postfix = "minute to read"
+ rt.plural = "minutes to read"
+
+ println(
+ "It will take ${rt.calcReadingTime()} ${ReadingTime.wordCount(rt.text)} words and " +
+ "${ReadingTime.imgCount(rt.text)} images at ${rt.wpm} words per minute."
+ )
+ } else {
+ System.err.println("The file could not be read or found.")
+ }
+ }
+ } else {
+ System.err.println("Please specify a file as an argument.")
+ }
+}
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index c1962a7..0000000
Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index 37aef8d..0000000
--- a/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
-networkTimeout=10000
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
deleted file mode 100755
index aeb74cb..0000000
--- a/gradlew
+++ /dev/null
@@ -1,245 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright © 2015-2021 the original authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-##############################################################################
-#
-# Gradle start up script for POSIX generated by Gradle.
-#
-# Important for running:
-#
-# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
-# noncompliant, but you have some other compliant shell such as ksh or
-# bash, then to run this script, type that shell name before the whole
-# command line, like:
-#
-# ksh Gradle
-#
-# Busybox and similar reduced shells will NOT work, because this script
-# requires all of these POSIX shell features:
-# * functions;
-# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
-# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
-# * compound commands having a testable exit status, especially «case»;
-# * various built-in commands including «command», «set», and «ulimit».
-#
-# Important for patching:
-#
-# (2) This script targets any POSIX shell, so it avoids extensions provided
-# by Bash, Ksh, etc; in particular arrays are avoided.
-#
-# The "traditional" practice of packing multiple parameters into a
-# space-separated string is a well documented source of bugs and security
-# problems, so this is (mostly) avoided, by progressively accumulating
-# options in "$@", and eventually passing that to Java.
-#
-# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
-# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
-# see the in-line comments for details.
-#
-# There are tweaks for specific operating systems such as AIX, CygWin,
-# Darwin, MinGW, and NonStop.
-#
-# (3) This script is generated from the Groovy template
-# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
-# within the Gradle project.
-#
-# You can find Gradle at https://github.com/gradle/gradle/.
-#
-##############################################################################
-
-# Attempt to set APP_HOME
-
-# Resolve links: $0 may be a link
-app_path=$0
-
-# Need this for daisy-chained symlinks.
-while
- APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
- [ -h "$app_path" ]
-do
- ls=$( ls -ld "$app_path" )
- link=${ls#*' -> '}
- case $link in #(
- /*) app_path=$link ;; #(
- *) app_path=$APP_HOME$link ;;
- esac
-done
-
-# This is normally unused
-# shellcheck disable=SC2034
-APP_BASE_NAME=${0##*/}
-APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD=maximum
-
-warn () {
- echo "$*"
-} >&2
-
-die () {
- echo
- echo "$*"
- echo
- exit 1
-} >&2
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "$( uname )" in #(
- CYGWIN* ) cygwin=true ;; #(
- Darwin* ) darwin=true ;; #(
- MSYS* | MINGW* ) msys=true ;; #(
- NONSTOP* ) nonstop=true ;;
-esac
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD=$JAVA_HOME/jre/sh/java
- else
- JAVACMD=$JAVA_HOME/bin/java
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD=java
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
- case $MAX_FD in #(
- max*)
- # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
- # shellcheck disable=SC3045
- MAX_FD=$( ulimit -H -n ) ||
- warn "Could not query maximum file descriptor limit"
- esac
- case $MAX_FD in #(
- '' | soft) :;; #(
- *)
- # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
- # shellcheck disable=SC3045
- ulimit -n "$MAX_FD" ||
- warn "Could not set maximum file descriptor limit to $MAX_FD"
- esac
-fi
-
-# Collect all arguments for the java command, stacking in reverse order:
-# * args from the command line
-# * the main class name
-# * -classpath
-# * -D...appname settings
-# * --module-path (only if needed)
-# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
-
-# For Cygwin or MSYS, switch paths to Windows format before running java
-if "$cygwin" || "$msys" ; then
- APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
- CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
-
- JAVACMD=$( cygpath --unix "$JAVACMD" )
-
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- for arg do
- if
- case $arg in #(
- -*) false ;; # don't mess with options #(
- /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
- [ -e "$t" ] ;; #(
- *) false ;;
- esac
- then
- arg=$( cygpath --path --ignore --mixed "$arg" )
- fi
- # Roll the args list around exactly as many times as the number of
- # args, so each arg winds up back in the position where it started, but
- # possibly modified.
- #
- # NB: a `for` loop captures its iteration list before it begins, so
- # changing the positional parameters here affects neither the number of
- # iterations, nor the values presented in `arg`.
- shift # remove old arg
- set -- "$@" "$arg" # push replacement arg
- done
-fi
-
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
-
-# Collect all arguments for the java command;
-# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
-# shell script including quotes and variable substitutions, so put them in
-# double quotes to make sure that they get re-expanded; and
-# * put everything else in single quotes, so that it's not re-expanded.
-
-set -- \
- "-Dorg.gradle.appname=$APP_BASE_NAME" \
- -classpath "$CLASSPATH" \
- org.gradle.wrapper.GradleWrapperMain \
- "$@"
-
-# Stop when "xargs" is not available.
-if ! command -v xargs >/dev/null 2>&1
-then
- die "xargs is not available"
-fi
-
-# Use "xargs" to parse quoted args.
-#
-# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
-#
-# In Bash we could simply go:
-#
-# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
-# set -- "${ARGS[@]}" "$@"
-#
-# but POSIX shell has neither arrays nor command substitution, so instead we
-# post-process each arg (as a line of input to sed) to backslash-escape any
-# character that might be a shell metacharacter, then use eval to reverse
-# that process (while maintaining the separation between arguments), and wrap
-# the whole thing up as a single "set" statement.
-#
-# This will of course break if any of these variables contains a newline or
-# an unmatched quote.
-#
-
-eval "set -- $(
- printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
- xargs -n1 |
- sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
- tr '\n' ' '
- )" '"$@"'
-
-exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
deleted file mode 100755
index 93e3f59..0000000
--- a/gradlew.bat
+++ /dev/null
@@ -1,92 +0,0 @@
-@rem
-@rem Copyright 2015 the original author or authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem https://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-@rem
-
-@if "%DEBUG%"=="" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%"=="" set DIRNAME=.
-@rem This is normally unused
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Resolve any "." and ".." in APP_HOME to make it shorter.
-for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if %ERRORLEVEL% equ 0 goto execute
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto execute
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
-
-:end
-@rem End local scope for the variables with windows NT shell
-if %ERRORLEVEL% equ 0 goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-set EXIT_CODE=%ERRORLEVEL%
-if %EXIT_CODE% equ 0 set EXIT_CODE=1
-if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
-exit /b %EXIT_CODE%
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/lib/bld/bld-wrapper.jar b/lib/bld/bld-wrapper.jar
new file mode 100644
index 0000000..69722e3
Binary files /dev/null and b/lib/bld/bld-wrapper.jar differ
diff --git a/lib/bld/bld-wrapper.properties b/lib/bld/bld-wrapper.properties
new file mode 100644
index 0000000..32712c6
--- /dev/null
+++ b/lib/bld/bld-wrapper.properties
@@ -0,0 +1,8 @@
+bld.downloadExtensionJavadoc=false
+bld.downloadExtensionSources=true
+bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.1
+bld.extensions=com.uwyn.rife2:bld-kotlin:0.9.0-SNAPSHOT
+bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
+bld.downloadLocation=
+bld.sourceDirectories=
+bld.version=1.7.5
diff --git a/settings.gradle.kts b/settings.gradle.kts
deleted file mode 100644
index 9f7a616..0000000
--- a/settings.gradle.kts
+++ /dev/null
@@ -1,18 +0,0 @@
-plugins {
- id("com.gradle.enterprise").version("3.6.3")
-}
-
-gradleEnterprise {
- buildScan {
- link("GitHub", "https://github.com/ethauvin/readingtime/tree/master")
- if (!System.getenv("CI").isNullOrEmpty()) {
- isUploadInBackground = false
- publishOnFailure()
- tag("CI")
- }
- termsOfServiceUrl = "https://gradle.com/terms-of-service"
- termsOfServiceAgree = "yes"
- }
-}
-
-rootProject.name = "readingtime"
diff --git a/sonar-project.properties b/sonar-project.properties
new file mode 100644
index 0000000..170f57b
--- /dev/null
+++ b/sonar-project.properties
@@ -0,0 +1,7 @@
+sonar.organization=ethauvin-github
+sonar.projectKey=ethauvin_readingtime
+sonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml
+sonar.sources=src/main/kotlin/
+sonar.tests=src/test/kotlin/
+sonar.java.binaries=build/main,build/test
+sonar.java.libraries=lib/compile/*.jar
diff --git a/src/bld/java/net/thauvin/erik/ReadingTimeBuild.java b/src/bld/java/net/thauvin/erik/ReadingTimeBuild.java
new file mode 100644
index 0000000..32a5303
--- /dev/null
+++ b/src/bld/java/net/thauvin/erik/ReadingTimeBuild.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2020-2023, Erik C. Thauvin (erik@thauvin.net)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * Neither the name of this project nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package net.thauvin.erik;
+
+import rife.bld.BuildCommand;
+import rife.bld.Project;
+import rife.bld.extension.CompileKotlinOperation;
+import rife.bld.extension.CompileKotlinOptions;
+import rife.bld.extension.JacocoReportOperation;
+import rife.bld.extension.dokka.DokkaOperation;
+import rife.bld.extension.dokka.LoggingLevel;
+import rife.bld.extension.dokka.OutputFormat;
+import rife.bld.operations.exceptions.ExitStatusException;
+import rife.bld.publish.PomBuilder;
+import rife.bld.publish.PublishDeveloper;
+import rife.bld.publish.PublishLicense;
+import rife.bld.publish.PublishScm;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import static rife.bld.dependencies.Repository.*;
+import static rife.bld.dependencies.Scope.compile;
+import static rife.bld.dependencies.Scope.test;
+
+public class ReadingTimeBuild extends Project {
+ public ReadingTimeBuild() {
+ pkg = "net.thauvin.erik";
+ name = "readingtime";
+ version = version(0, 9, 2, "SNAPSHOT");
+
+ javaRelease = 11;
+ downloadSources = true;
+ autoDownloadPurge = true;
+ repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL);
+
+ scope(compile)
+ .include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", version(1, 9, 20)))
+ .include(dependency("org.jsoup", "jsoup", version(1, 16, 2)));
+ scope(test)
+ .include(dependency("org.jetbrains.kotlin:kotlin-test-junit5:1.9.20"))
+ .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 1)))
+ .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 1)));
+
+ publishOperation()
+ .repository(version.isSnapshot() ? SONATYPE_SNAPSHOTS_LEGACY : SONATYPE_RELEASES_LEGACY)
+ .info()
+ .groupId(pkg)
+ .artifactId(name)
+ .description("Estimated Reading Time for Blog Posts, Articles, etc.")
+ .url("https://github.com/ethauvin/" + name)
+ .developer(new PublishDeveloper()
+ .id("ethauvin")
+ .name("Erik C. Thauvin")
+ .email("erik@thauvin.net")
+ .url("https://erik.thauvin.net/"))
+ .license(new PublishLicense()
+ .name("BSD 3-Clause")
+ .url("https://opensource.org/licenses/BSD-3-Clause"))
+ .scm(new PublishScm()
+ .connection("scm:git:https://github.com/ethauvin/" + name)
+ .developerConnection("scm:git:git@github.com:ethauvin/" + name + ".git")
+ .url("https://github.com/ethauvin/" + name))
+ .signKey(property("sign.key"))
+ .signPassphrase(property("sign.passphrase"));
+
+ jarSourcesOperation().sourceDirectories(new File(srcMainDirectory(), "kotlin"));
+ }
+
+ public static void main(String[] args) {
+ new ReadingTimeBuild().start(args);
+ }
+
+ @BuildCommand(summary = "Compilez the Kotlin project")
+ @Override
+ public void compile() throws IOException {
+ new CompileKotlinOperation()
+ .fromProject(this)
+ .compileOptions(
+ new CompileKotlinOptions()
+ .jdkRelease(javaRelease)
+ .verbose(true)
+ )
+ .execute();
+ }
+
+ @BuildCommand(summary = "Generates JaCoCo Reports")
+ public void jacoco() throws IOException {
+ new JacocoReportOperation()
+ .fromProject(this)
+ .execute();
+ }
+
+ @Override
+ public void javadoc() throws ExitStatusException, IOException, InterruptedException {
+ new DokkaOperation()
+ .fromProject(this)
+ .loggingLevel(LoggingLevel.INFO)
+ .outputDir(new File(buildDirectory(), "javadoc"))
+ .outputFormat(OutputFormat.JAVADOC)
+ .execute();
+ }
+
+ @Override
+ public void publish() throws Exception {
+ super.publish();
+ PomBuilder.generateInto(publishOperation().info(), publishOperation().dependencies(),
+ new File(workDirectory, "pom.xml"));
+ }
+}
diff --git a/src/main/kotlin/net/thauvin/erik/readingtime/ReadingTime.kt b/src/main/kotlin/net/thauvin/erik/readingtime/ReadingTime.kt
index fbcc356..77f0261 100644
--- a/src/main/kotlin/net/thauvin/erik/readingtime/ReadingTime.kt
+++ b/src/main/kotlin/net/thauvin/erik/readingtime/ReadingTime.kt
@@ -1,20 +1,18 @@
/*
- * ReadingTime.kt
- *
- * Copyright (c) 2020-2022, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2020-2023, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
- * Redistributions of source code must retain the above copyright notice, this
+ * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
- * Redistributions in binary form must reproduce the above copyright notice,
+ * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
- * Neither the name of this project nor the names of its contributors may be
+ * Neither the name of this project nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
@@ -124,7 +122,7 @@ class ReadingTime @JvmOverloads constructor(
}
/**
- * Calculates and returns the reading time. (eg. 1 min read)
+ * Calculates and returns the reading time. (e.g. 1 min read)
*
* `(reading time in sec / 60) + postfix`
*/
diff --git a/src/main/resources/META-INF/tags/readingtime.tag b/src/main/resources/META-INF/tags/readingtime.tag
index 4d2a771..e8c3bcb 100644
--- a/src/main/resources/META-INF/tags/readingtime.tag
+++ b/src/main/resources/META-INF/tags/readingtime.tag
@@ -1,5 +1,5 @@
<%--
- Copyright (c) 2020-2022, Erik C. Thauvin (erik@thauvin.net)
+ Copyright (c) 2020-2023, Erik C. Thauvin (erik@thauvin.net)
All rights reserved.
See: https://erik.thauvin.net/licenses/bsd.shtml
diff --git a/src/test/kotlin/net/thauvin/erik/readingtime/ReadingTimeTest.kt b/src/test/kotlin/net/thauvin/erik/readingtime/ReadingTimeTest.kt
index ca92941..ebb57bd 100644
--- a/src/test/kotlin/net/thauvin/erik/readingtime/ReadingTimeTest.kt
+++ b/src/test/kotlin/net/thauvin/erik/readingtime/ReadingTimeTest.kt
@@ -1,20 +1,18 @@
/*
- * ReadingTimeTest.kt
- *
- * Copyright (c) 2020-2022, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2020-2023, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
- * Redistributions of source code must retain the above copyright notice, this
+ * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
- * Redistributions in binary form must reproduce the above copyright notice,
+ * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
- * Neither the name of this project nor the names of its contributors may be
+ * Neither the name of this project nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*