RunIcal

CI

Generate ical files based on Hal Higdon's training programs.

Installation

Add this line to your application's Gemfile:

gem 'run_ical'

And then execute:

$ bundle

Or install it yourself as:

$ gem install run_ical

Usage

The following command will return the ical file as a string:

RunIcal::Generator.generate(race_date: "2018-05-06", program: "Advanced5K")

You can also generate from the CLI interface:

run_ical --program=Advanced5K --date=2018-05-06 --file=/tmp/cal.ical

The plan is anchored to race_date and counted backwards, so the last day of the program always lands on race day.

Programs

Distance program: values
5K Novice5K, Intermediate5K, Advanced5K, Walkers5K
8K Novice8K, Intermediate8K, Advanced8K
10K Novice10K, Intermediate10K, Advanced10K, Walking10K
15K / 10 mile Novice15K, Intermediate15K, Advanced15K
Half marathon HalfMarathonNovice1, HalfMarathonNovice2, HalfMarathonIntermediate1, HalfMarathonIntermediate2, HalfMarathonAdvanced, HalfMarathonHM3, HalfMarathonWalkers
Marathon MarathonNovice1, MarathonNovice2, MarathonIntermediate1, MarathonIntermediate2, MarathonAdvanced1, MarathonAdvanced2, MarathonNoviceSupreme, MarathonPersonalBest, MarathonSenior, Marathon3, MarathonBostonBound, MarathonDopeyChallenge

MarathonBostonBound ends on a Monday (Patriots' Day); every other program ends on a Sunday.

Listing programs

RunIcal::Data.constants returns programs in load order, which is alphabetical by filename and puts every Advanced plan ahead of every Novice one. To present them to users, use the ordered helpers instead — distance ascending, then difficulty:

RunIcal::Data.programs        # => [Novice5K, Intermediate5K, Advanced5K, Walkers5K, Novice8K, ...]
RunIcal::Data.by_distance     # => { "5-K" => [...], "8-K" => [...], ..., "Marathon" => [...] }
RunIcal::Data.find("Novice5K")

Each program exposes DISTANCE, LEVEL, POSITION and DESCRIPTION ("<DISTANCE> - <LEVEL>"). Display order is the order of tasks/higdon_programs.yml — reorder there and re-run the refresh to change it.

Development

Refreshing the training data

The plans in lib/run_ical/data are scraped from halhigdon.com. tasks/higdon_programs.yml maps each program to its source page, and:

bundle exec rake data:refresh            # every program
bundle exec rake data:refresh[Novice5K]  # just one

rewrites the .yaml plan data and its .rb loader. The task aborts rather than write a plan whose week count changed, whose cells went blank, or that no longer ends on race day. Run rake spec afterwards — the specs re-check every program. Adding a program is a new manifest entry plus a refresh; lib/run_ical.rb picks up the file automatically.

Setup

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/scashin133/run_ical.

License

The gem is available as open source under the terms of the MIT License.