@@ -6,23 +6,18 @@ class LearningObjective {
66 int chapter
77 int chapterIndex
88
9-
109 LearningObjective (String id , String title , String chapter , String chapterIndex ) {
11- this . id = id
12- this . title = title
13- this . chapter = Integer . valueOf(chapter)
14- this . chapterIndex = Integer . valueOf(chapterIndex)
10+ this . id = id
11+ this . title = title
12+ this . chapter = Integer . valueOf(chapter)
13+ this . chapterIndex = Integer . valueOf(chapterIndex)
1514 }
1615}
1716
1817task includeLearningObjectives (
1918 description : ' collect learning objectives from source files and include them as listing' ,
2019 group : ' isaqb-curriculum'
2120) {
22- doFirst {
23- buildDir. mkdirs()
24- }
25-
2621 doLast {
2722 def contentDE = createLearningObjectivesContent(" DE" , ~/ \[\[ (LZ-\d *-\d *)\]\]\s *==== (LZ (\d *)-(\d *).*)/ , " Verzeichnis der Lernziele" )
2823 def contentEN = createLearningObjectivesContent(" EN" , ~/ \[\[ (LG-\d *-\d *)\]\]\s *==== (LG (\d *)-(\d *).*)/ , " List of Learning Goals" )
@@ -41,63 +36,66 @@ task includeLearningObjectives(
4136 ext. collectLearningObjectives = { pattern ->
4237 def docsFolder = new File (projectDir, ' /docs' )
4338 def learningObjectives = []
39+
4440 docsFolder. traverse(type : FILES ) { file ->
45- if (file. name ==~ ' .*[.](ad|adoc|asciidoc)$' ) {
41+
42+ if (file. name ==~ ' .*[.](ad|adoc|asciidoc)$' ) {
4643 def content = file. text
4744 def matcher = content =~ pattern
4845
49- while ( matcher) {
50- def id = matcher . group( 1 )
51- def title = matcher . group(2 )
52- def chapter = matcher . group(3 )
53- def chapterIndex = matcher . group(4 )
54- learningObjectives . add(
55- new LearningObjective (id, title, chapter, chapterIndex))
46+ for (result in matcher. results() ) {
47+
48+ def id = result . group(1 )
49+ def title = result . group(2 )
50+ def chapter = result . group(3 )
51+ def chapterIndex = result . group( 4 )
52+ learningObjectives . add( new LearningObjective (id, title, chapter, chapterIndex))
5653 }
5754 }
5855 }
5956
6057 return learningObjectives
6158 }
59+ }
6260
63- ext. sortLearningObjectives = { learningObjectives ->
64- learningObjectives. sort { a , b ->
65- if (a. chapter == b. chapter) {
66- a. chapterIndex <=> b. chapterIndex
67- } else {
68- a. chapter <=> b. chapter
69- }
61+ ext. sortLearningObjectives = { learningObjectives ->
62+ learningObjectives. sort { a , b ->
63+ if (a. chapter == b. chapter) {
64+ a. chapterIndex <=> b. chapterIndex
65+ } else {
66+ a. chapter <=> b. chapter
7067 }
7168 }
69+ }
7270
73- ext. compileLearningObjectives = { language , headline , learningObjectives ->
74- def content = ' ' << ' '
71+ ext. compileLearningObjectives = { language , headline , learningObjectives ->
72+ def content = ' ' << ' '
7573
76- content << = " // tag::" + language + " []\n "
77- content << = " == " + headline + " \n\n "
74+ content << = " // tag::" + language + " []\n "
75+ content << = " == " + headline + " \n\n "
7876
79- learningObjectives. each { learningObjective ->
80- content << = " - <<" + learningObjective. id + " , " + learningObjective. title + " >>\n "
81- }
77+ learningObjectives. each { learningObjective ->
78+ content << = " - <<" + learningObjective. id + " , " + learningObjective. title + " >>\n "
79+ }
8280
83- content << = " // end::" + language + " []\n "
81+ content << = " // end::" + language + " []\n "
8482
85- return content. toString()
86- }
83+ return content. toString()
84+ }
8785
88- ext. writeLearningObjectives = { contentDE , contentEN ->
89- def docsFolder = new File (projectDir, ' /docs' )
90- def outFile = new File (docsFolder, ' /learning-objectives.adoc' )
86+ ext. writeLearningObjectives = { contentDE , contentEN ->
87+ def docsFolder = new File (projectDir, ' /docs' )
88+ def outFile = new File (docsFolder, ' /learning-objectives.adoc' )
9189
92- println " Learning objectives file: " + outFile. getAbsolutePath()
90+ println " Learning objectives file: " + outFile. getAbsolutePath()
9391
94- final String EMPTYRemark = """ // tag::REMARK[]\n // end::REMARK[]\n """
92+ final String EMPTYRemark = """ // tag::REMARK[]\n // end::REMARK[]\n """
9593
96- outFile. withWriter(' UTF-8' ) { writer ->
97- writer. writeLine(" // this is autogenerated - please do not modify manually!\n " )
98- writer. writeLine(contentDE)
99- writer. writeLine(contentEN)
100- writer. writeLine(EMPTYRemark )
101- }
94+ outFile. withWriter(' UTF-8' ) { writer ->
95+ writer. writeLine(" // this is autogenerated - please do not modify manually!\n " )
96+ writer. writeLine(contentDE)
97+ writer. writeLine(contentEN)
98+ writer. writeLine(EMPTYRemark )
10299 }
103100}
101+
0 commit comments