Skip to content

Commit

Permalink
#274 first version
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmueller committed Feb 26, 2019
1 parent a752acf commit c25ac52
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion changelog.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ and this project tries to adhere to https://semver.org/spec/v2.0.0.html[Semantic
=== Added

2019-02-26::
- first draft of `exportMetrics` task
- first version of `exportMetrics` task

=== Changed

Expand Down
13 changes: 9 additions & 4 deletions scripts/exportMetrics.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//tag::exportMetrics[]
import static groovy.io.FileType.*
import java.security.MessageDigest

task exportMetrics(
description: 'exports some metrics for your texts',
Expand All @@ -11,15 +10,21 @@ task exportMetrics(
println "sourceFolder: " + sourceFolder.canonicalPath
def targetFile = new File(targetDir, "metrics.csv")
targetFile.write("date, numWords, file\n")
def sumWords = 0
sourceFolder.traverse(type: FILES) { file ->
if (file.name ==~ '^.*[.](ad|adoc|asciidoc)$') {
def currentFileName = file.canonicalPath.replace("\\", "\\\\")
def numWords = getNumWords(currentFileName)
println("\u023F1 $numWords in File $currentFileName")
targetFile.append("${new Date().format('YYYY.MM.dd')}, $numWords, $currentFileName\n")
Integer numWords = getNumWords(currentFileName)
println("${numWords.toString().padLeft(6)} words in File ${currentFileName-sourceFolder}")
def currentDate = new Date().format('YYYY.MM.dd')
targetFile.append("${currentDate}, ${numWords.toString().padLeft(6)}, ${currentFileName-sourceFolder}\n")
sumWords += numWords
}
}
println "======"
println "${sumWords.toString().padLeft(6)} words overall"
println ""
println sourceFolder
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/docs/manual/03_task_exportContributors.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ ifndef::imagesdir[:imagesdir: ../images]
include::feedback.adoc[]

This tasks crawls through all asciidoctor source files and extracts a list of contributors.
This list is then rendred as asciidoc images of the contributor's gravatar picture.
This list is then rendered as asciidoc images of the contributor's gravatar picture.
11 changes: 11 additions & 0 deletions src/docs/manual/03_task_exportMetrics.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
:filename: manual/03_task_exportMetrics.adoc
ifndef::imagesdir[:imagesdir: ../images]

= exportMetrics

include::feedback.adoc[]

This tasks crawls through all asciidoctor source files and extracts the number of words in each file.
At the end, it displays the number of words overall.

This task ist currently only intended to give you an output on the commandline to measure your writing progress.

0 comments on commit c25ac52

Please sign in to comment.