diff --git a/README.md b/README.md index 06c3765..7e9b41b 100644 --- a/README.md +++ b/README.md @@ -93,12 +93,14 @@ The reserved keywords of the notation are: workout, warmup, cooldown, run, bike, **``** := `:` -**``** := ` | ` +**``** := ` | | ` **``** := `z[1-6]` **``** := ` - (mpk | mpm)?` +**``** := `\d{1,3} - \d{1,3} bpm` + **``** := ` - (kph | mph)?` **``** := `:` @@ -109,6 +111,8 @@ The reserved keywords of the notation are: workout, warmup, cooldown, run, bike, **``** := `\d{2}` +**``** := `[\r\n]` + ## Unit of measurements (metric vs imperial) As Garmin supports metric and imperial measurement systems, quick-plan can do this as well. There are two ways of usage: diff --git a/src/main/scala/com.github.mgifos.workouts/model/Step.scala b/src/main/scala/com.github.mgifos.workouts/model/Step.scala index 7fedf84..90db5bb 100644 --- a/src/main/scala/com.github.mgifos.workouts/model/Step.scala +++ b/src/main/scala/com.github.mgifos.workouts/model/Step.scala @@ -52,7 +52,7 @@ case class RepeatStep(count: Int, steps: Seq[Step]) extends Step { object Step { - private val StepRx = """^(-\s\w*:\s.*)((\n\s{1,}-\s.*)*)$""".r + private val StepRx = """^(-\s\w*:\s.*)(([\r\n]+\s{1,}-\s.*)*)$""".r private val StepHeader = """^\s*-\s*(\w*):(.*)$""".r private val ParamsRx = """^([\w-\.:\s]+)\s*(@(.*))?$""".r diff --git a/src/main/scala/com.github.mgifos.workouts/model/Workout.scala b/src/main/scala/com.github.mgifos.workouts/model/Workout.scala index fb0f76b..3df6d75 100644 --- a/src/main/scala/com.github.mgifos.workouts/model/Workout.scala +++ b/src/main/scala/com.github.mgifos.workouts/model/Workout.scala @@ -34,8 +34,8 @@ case class WorkoutNote(note: String) extends Workout { object Workout { - private val WorkoutHeader = """^(running|cycling):\s([\u0020-\u007F]+)((\n\s*\-\s[a-z]+:.*)*)$""".r - private val NextStepRx = """^((-\s\w*:\s.*)((\n\s{1,}-\s.*)*))(([\s].*)*)$""".r + private val WorkoutHeader = """^(running|cycling):\s([\u0020-\u007F]+)(([\r\n]+\s*\-\s[a-z]+:.*)*)$""".r + private val NextStepRx = """^((-\s\w*:\s.*)(([\r\n]+\s{1,}-\s.*)*))(([\s].*)*)$""".r def parseDef(x: String)(implicit msys: MeasurementSystems.MeasurementSystem): Either[String, WorkoutDef] = { def loop(w: WorkoutDef, steps: String): Either[String, WorkoutDef] = steps match { diff --git a/src/test/scala/com/github/mgifos/workouts/model/WorkoutSpec.scala b/src/test/scala/com/github/mgifos/workouts/model/WorkoutSpec.scala index 3fdf86d..8155b37 100644 --- a/src/test/scala/com/github/mgifos/workouts/model/WorkoutSpec.scala +++ b/src/test/scala/com/github/mgifos/workouts/model/WorkoutSpec.scala @@ -53,7 +53,7 @@ class WorkoutSpec extends FlatSpec with Matchers { } "Workout" should "support cycling ws" in { - val testBike = "cycling: cycle-test\n- warmup: 5:00\n- bike: 20km @ 20.0-100kph\n- cooldown: lap-button" + val testBike = "cycling: cycle-test\r\n- warmup: 5:00\n- bike: 20km @ 20.0-100kph\r- cooldown: lap-button" Workout.parseDef(testBike) should be( Right( WorkoutDef("cycling", "cycle-test", Seq(