Skip to content

Commit b938a04

Browse files
authored
Merge pull request #12 from mgifos/wo-names-8
Fixed: workout names #8
2 parents a88c8f8 + 3aa27ef commit b938a04

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Checkout a [complete training plan for 80K ultra](https://docs.google.com/spread
3232
- Java 8 is a prerequisite, make sure you have it installed
3333
- Go to the [releases page](https://github.com/mgifos/quick-plan/releases) of this project
3434
- Download latest release zip file and unzip it somewhere on your computer
35-
- Enter bin folder and run `quick-plan` command (use `quick-plan.bat` if you are a Windows user)
35+
- Enter bin folder and run `quick-plan` command (use `quick-plan.bat` if you are a Windows user or mark quick-plan script as executable on Linux or Mac systems)
3636

3737
## Command line options
3838

@@ -73,6 +73,8 @@ The reserved keywords of the notation are: workout, warmup, cooldown, run, repea
7373

7474
**`<header>`** := `workout: <name>`
7575

76+
**`<name>`** := `[\u0020-\u007F]+` (printable ascii characters)
77+
7678
**`<step>`** := `<newline>- <step-def>`
7779

7880
**`<step-def>`** := `<simple-step> | <repetition-step>`

src/main/scala/com.github.mgifos.workouts/model/Workout.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ case class WorkoutNote(note: String) extends Workout {
3333

3434
object Workout {
3535

36-
private val WorkoutName = """^workout:\s([\w \-,;:\.@]+)((\n\s*\-\s[a-z]+:.*)*)$""".r
36+
private val WorkoutName = """^workout:\s([\u0020-\u007F]+)((\n\s*\-\s[a-z]+:.*)*)$""".r
3737
private val NextStepRx = """^((-\s\w*:\s.*)((\n\s{1,}-\s.*)*))(([\s].*)*)$""".r
3838

3939
def parseDef(x: String): Either[String, WorkoutDef] = {

src/test/scala/com/github/mgifos/workouts/model/WorkoutSpec.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ class WorkoutSpec extends FlatSpec with Matchers {
3434
CooldownStep(LapButtonPressed)))))
3535
}
3636

37+
"Workout" should "parse various printable workout-names correctly" in {
38+
39+
val testNames = Seq("abcz", "123 xyw", """abc!/+-@,?*;:_!\"#$%&/()=?*""")
40+
41+
testNames.foreach { testName =>
42+
val x = Workout.parseDef(testWO.replace("run-fast", testName))
43+
println(x)
44+
x.right.get.name should be(testName)
45+
}
46+
}
47+
48+
3749
"Workout" should "dump json correctly" in {
3850
val is = getClass.getClassLoader.getResourceAsStream("run-fast.json")
3951
val expectJson = Json.parse(is)

0 commit comments

Comments
 (0)