Skip to content

Commit

Permalink
Additional step type 'go' provided to support custom workouts fully #29
Browse files Browse the repository at this point in the history
  • Loading branch information
mgifos committed Nov 20, 2018
1 parent 611f6ba commit 55e1c1a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ quick-plan schedule -n 2018-04-29 -x -e your-mail-address@example.com ultra-80k-
```

## Workout notation
The reserved keywords of the notation are: workout, warmup, cooldown, run, bike, repeat, recover and lap-button.
The reserved keywords of the notation are: workout, warmup, cooldown, run, bike, go, repeat, recover and lap-button.

**`<workout>`** := `<header><step>+`

Expand All @@ -83,7 +83,7 @@ The reserved keywords of the notation are: workout, warmup, cooldown, run, bike,

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

**`<simple-step>`** := `(warmup | cooldown | run | bike | recover): <duration> [@ <target>]`
**`<simple-step>`** := `(warmup | cooldown | run | bike | go | recover): <duration> [@ <target>]`

**`<repetition-step>`** := `repeat: <count>(<newline> - <simple-step>)+`

Expand Down Expand Up @@ -126,6 +126,6 @@ If not specified -m value from configuration will be used ('metric' by default).

## Known issues

- It is highly recommanded to use Google Spreadsheets or LibreOffice Calc to edit CSV files, as they both force line-feed (LF)
- It is highly recommended to use Google Spreadsheets or LibreOffice Calc to edit CSV files, as they both force line-feed (LF)
instead of carriage-return (CR) character for internal line breaks when defining workouts.
The parser we use is not able to parse CR values within the quoted values at the moment.
2 changes: 1 addition & 1 deletion src/main/scala/com.github.mgifos.workouts/model/Step.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ object Step {
private def parseDurationStep(x: String)(implicit msys: MeasurementSystems.MeasurementSystem): DurationStep = x match {
case StepHeader(name, params) => name match {
case "warmup" => WarmupStep.tupled(expect(params))
case "run" | "bike" => IntervalStep.tupled(expect(params))
case "run" | "bike" | "go" => IntervalStep.tupled(expect(params))
case "recover" => RecoverStep.tupled(expect(params))
case "cooldown" => CooldownStep.tupled(expect(params))
case _ => throw new IllegalArgumentException(s"Duration step type was expected, $name")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class StepSpec extends FlatSpec with Matchers {

Step.parse("- warmup: 5km") should be(WarmupStep(DistanceDuration(5, km)))
Step.parse("- run: 2km @ 5:00-4:50") should be(IntervalStep(DistanceDuration(2, km), Some(PaceTarget(Pace(msys.distance, "5:00"), Pace(msys.distance, "4:50")))))
Step.parse("- bike: 2km @ 20-30 kph") should be(IntervalStep(DistanceDuration(2, km), Some(SpeedTarget(Speed(msys.distance, "20"), Speed(msys.distance, "30")))))
Step.parse("- go: 20km @ 9:00-11:00") should be(IntervalStep(DistanceDuration(20, km), Some(PaceTarget(Pace(msys.distance, "9:00"), Pace(msys.distance, "11:00")))))
Step.parse("- recover: 500m @z2") should be(RecoverStep(DistanceDuration(500, m), Some(HrZoneTarget(2))))
Step.parse("- cooldown: 05:00") should be(CooldownStep(TimeDuration(minutes = 5)))
Step.parse("- repeat: 3\n - run: 10km\n - recover: 100m") should be(RepeatStep(3, List(
Expand Down

0 comments on commit 55e1c1a

Please sign in to comment.