-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
34c1a65
commit 3fc9ad1
Showing
5 changed files
with
86 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env ruby | ||
|
||
begin | ||
require "bundler/setup" | ||
rescue LoadError | ||
end | ||
|
||
begin | ||
require 'runby_pace' | ||
rescue LoadError | ||
require_relative '../lib/runby_pace' | ||
end | ||
|
||
cli = Runby::Cli.new(ARGV) | ||
exit cli.run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'readline' | ||
|
||
module Runby | ||
# Command line interface and REPL for RunbyPace | ||
class Cli | ||
def initialize(args = ARGV) | ||
@args = args | ||
end | ||
|
||
def run | ||
puts 'Runby Pace REPL!' | ||
bnd = binding | ||
while (input = Readline.readline('🏃 ', true)) | ||
begin | ||
result = bnd.eval input | ||
rescue StandardError => e | ||
puts "#{e.class}: #{e.message}" | ||
else | ||
puts result | ||
end | ||
end | ||
end | ||
|
||
def targets(five_k_time, distance_units = :mi) | ||
five_k_time = Runby.sanitize(five_k_time).as(RunbyTime) | ||
puts "\nIf you can run a 5K in #{five_k_time}, your training paces should be:" | ||
RunTypes.all_classes.each do |run_type| | ||
run = run_type.new | ||
puts " #{run.description}: #{run.lookup_pace(five_k_time, distance_units)}" | ||
end | ||
nil | ||
end | ||
|
||
# -- Shortcuts | ||
def d(*args) | ||
Distance.new(*args) | ||
end | ||
|
||
def du(*args) | ||
DistanceUnit.new(*args) | ||
end | ||
|
||
def p(*args) | ||
Pace.new(*args) | ||
end | ||
|
||
def s(*args) | ||
Speed.new(*args) | ||
end | ||
|
||
def t(*args) | ||
RunbyTime.new(*args) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module Runby | ||
VERSION = "0.6.#{`git rev-list --count HEAD`}" | ||
VERSION = "0.61.#{`git rev-list --count HEAD`}" | ||
end |