Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: workout names #8 #12

Merged
merged 1 commit into from
May 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Checkout a [complete training plan for 80K ultra](https://docs.google.com/spread
- Java 8 is a prerequisite, make sure you have it installed
- Go to the [releases page](https://github.com/mgifos/quick-plan/releases) of this project
- Download latest release zip file and unzip it somewhere on your computer
- Enter bin folder and run `quick-plan` command (use `quick-plan.bat` if you are a Windows user)
- 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)

## Command line options

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

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

**`<name>`** := `[\u0020-\u007F]+` (printable ascii characters)

**`<step>`** := `<newline>- <step-def>`

**`<step-def>`** := `<simple-step> | <repetition-step>`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ case class WorkoutNote(note: String) extends Workout {

object Workout {

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

def parseDef(x: String): Either[String, WorkoutDef] = {
Expand Down
12 changes: 12 additions & 0 deletions src/test/scala/com/github/mgifos/workouts/model/WorkoutSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ class WorkoutSpec extends FlatSpec with Matchers {
CooldownStep(LapButtonPressed)))))
}

"Workout" should "parse various printable workout-names correctly" in {

val testNames = Seq("abcz", "123 xyw", """abc!/+-@,?*;:_!\"#$%&/()=?*""")

testNames.foreach { testName =>
val x = Workout.parseDef(testWO.replace("run-fast", testName))
println(x)
x.right.get.name should be(testName)
}
}


"Workout" should "dump json correctly" in {
val is = getClass.getClassLoader.getResourceAsStream("run-fast.json")
val expectJson = Json.parse(is)
Expand Down