runby_pace 0.2.50.111 → 0.2.55

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +13 -5
  2. data/.travis.yml +1 -5
  3. data/Gemfile +0 -4
  4. data/README.md +5 -16
  5. data/Rakefile +6 -40
  6. data/bin/_guard-core +16 -17
  7. data/bin/guard +16 -17
  8. data/lib/runby_pace.rb +1 -4
  9. data/lib/runby_pace/{pace_calculator.rb → pace_data.rb} +13 -29
  10. data/lib/runby_pace/pace_range.rb +9 -27
  11. data/lib/runby_pace/pace_time.rb +110 -0
  12. data/lib/runby_pace/run_type.rb +4 -12
  13. data/lib/runby_pace/run_types/all_run_types.template +4 -6
  14. data/lib/runby_pace/run_types/easy_run.rb +10 -31
  15. data/lib/runby_pace/run_types/find_divisor.rb +17 -13
  16. data/lib/runby_pace/run_types/long_run.rb +10 -32
  17. data/lib/runby_pace/version.rb +2 -17
  18. data/runby_pace.gemspec +5 -4
  19. metadata +18 -41
  20. data/.rubocop.yml +0 -10
  21. data/bin/runbypace +0 -15
  22. data/lib/runby_pace/cli/cli.rb +0 -127
  23. data/lib/runby_pace/cli/config.rb +0 -82
  24. data/lib/runby_pace/distance.rb +0 -135
  25. data/lib/runby_pace/distance_unit.rb +0 -89
  26. data/lib/runby_pace/golden_pace_set.rb +0 -50
  27. data/lib/runby_pace/pace.rb +0 -152
  28. data/lib/runby_pace/run_math.rb +0 -14
  29. data/lib/runby_pace/run_types/distance_run.rb +0 -55
  30. data/lib/runby_pace/run_types/fast_tempo_run.rb +0 -23
  31. data/lib/runby_pace/run_types/five_kilometer_race_run.rb +0 -22
  32. data/lib/runby_pace/run_types/mile_race_run.rb +0 -24
  33. data/lib/runby_pace/run_types/slow_tempo_run.rb +0 -22
  34. data/lib/runby_pace/run_types/tempo_run.rb +0 -54
  35. data/lib/runby_pace/run_types/ten_kilometer_race_run.rb +0 -23
  36. data/lib/runby_pace/runby_range.rb +0 -22
  37. data/lib/runby_pace/runby_time.rb +0 -138
  38. data/lib/runby_pace/runby_time_parser.rb +0 -80
  39. data/lib/runby_pace/speed.rb +0 -97
  40. data/lib/runby_pace/speed_range.rb +0 -30
  41. data/lib/runby_pace/utility/parameter_sanitizer.rb +0 -29
  42. data/lib/runby_pace/version.seed +0 -5
  43. data/misc/runbypace_logo.png +0 -0
@@ -1,26 +1,18 @@
1
- # frozen_string_literal: true
1
+ module RunbyPace
2
2
 
3
- module Runby
4
- # Base class for all run types
5
3
  class RunType
6
4
  def description
7
5
  'No description'
8
6
  end
9
7
 
10
- def explanation
11
- 'No explanation'
8
+ def pace(five_k_time)
12
9
  end
13
-
14
- def lookup_pace(five_k_time, distance_units = :km) end
15
10
  end
16
11
 
17
- # Extends RunTypes with additional methods.
18
- # Since RunTypes is autogenerated in all_run_types.g.rb, we needed a safe way of adding behavior to it
19
- # without complicating the codegen.
20
12
  module RunTypes
21
- # Returns an initialized run type, given the name of an existing run type
22
13
  def self.new_from_name(run_type_name)
23
- Object.const_get("Runby::RunTypes::#{run_type_name}").new
14
+ Object::const_get("RunbyPace::RunTypes::#{run_type_name}").new
24
15
  end
25
16
  end
17
+
26
18
  end
@@ -1,14 +1,12 @@
1
1
  # This file is automatically generated by a rake task
2
2
 
3
- module Runby
4
- # Encapsulates data and behavior relating to all run types.
3
+ module RunbyPace
4
+
5
5
  module RunTypes
6
+
6
7
  def self.all
7
- %w[__RUN_TYPE_NAMES__]
8
+ %w(__RUN_TYPES__)
8
9
  end
9
10
 
10
- def self.all_classes
11
- [__RUN_TYPES__]
12
- end
13
11
  end
14
12
  end
@@ -1,52 +1,31 @@
1
- # frozen_string_literal: true
1
+ module RunbyPace
2
2
 
3
- module Runby
4
3
  module RunTypes
5
- # An easy run is basically a jog. It should be conversational.
4
+
6
5
  class EasyRun < RunType
7
- attr_reader :slow_pace_calculator, :fast_pace_calculator
6
+ attr_reader :slow_pace_data, :fast_pace_data
8
7
 
9
8
  def description
10
9
  'Easy Run'
11
10
  end
12
11
 
13
- def explanation
14
- 'Also called a recovery run, the easy run is harder than jogging, but you should still be able to carry on a conversation.'
15
- end
16
-
17
12
  def initialize
18
- @fast_pace_calculator = PaceCalculator.new(GoldenPaces.fast, 1.99)
19
- @slow_pace_calculator = PaceCalculator.new(GoldenPaces.slow, 1.35)
13
+ @fast_pace_data = PaceData.new(GoldenPaces::fast[:'14:00'], GoldenPaces::fast[:'42:00'], 1.99)
14
+ @slow_pace_data = PaceData.new(GoldenPaces::slow[:'14:00'], GoldenPaces::slow[:'42:00'], 1.35)
20
15
  end
21
16
 
22
- def lookup_pace(five_k_time, distance_units = :km)
23
- fast = @fast_pace_calculator.calc(five_k_time, distance_units)
24
- slow = @slow_pace_calculator.calc(five_k_time, distance_units)
17
+ def pace(five_k_time)
18
+ fast = @fast_pace_data.calc(five_k_time)
19
+ slow = @slow_pace_data.calc(five_k_time)
25
20
  PaceRange.new(fast, slow)
26
21
  end
27
22
 
28
- # Used in testing, contains hashes mapping 5K race times with the recommended pace-per-km for this run type.
29
23
  class GoldenPaces
30
24
  def self.fast
31
- GoldenPaceSet.new('14:00': '04:17',
32
- '15:00': '04:33',
33
- '20:00': '05:53',
34
- '25:00': '07:09',
35
- '30:00': '08:23',
36
- '35:00': '09:33',
37
- '40:00': '10:41',
38
- '42:00': '11:08')
25
+ { '14:00': '04:17', '15:00': '04:33', '20:00': '05:53', '25:00': '07:09', '30:00': '08:23', '35:00': '09:33', '40:00': '10:41', '42:00': '11:08'}
39
26
  end
40
-
41
27
  def self.slow
42
- GoldenPaceSet.new('14:00': '05:01',
43
- '15:00': '05:20',
44
- '20:00': '06:51',
45
- '25:00': '08:17',
46
- '30:00': '09:38',
47
- '35:00': '10:56',
48
- '40:00': '12:10',
49
- '42:00': '12:39')
28
+ { '14:00': '05:01', '15:00': '05:20', '20:00': '06:51', '25:00': '08:17', '30:00': '09:38', '35:00': '10:56', '40:00': '12:10', '42:00': '12:39'}
50
29
  end
51
30
  end
52
31
  end
@@ -1,43 +1,47 @@
1
- # frozen_string_literal: true
1
+ module RunbyPace
2
2
 
3
- module Runby
4
- # Extend RunTypes with additional behavior. (See comments for details)
5
3
  module RunTypes
4
+
6
5
  # Currently, to find the radius of the curve in the pace table data for a given run time,
7
6
  # we start with a radius equal to that of the midpoint of the X axis for the data when
8
- # plotted on a graph. Then we use a radius divisor for the PaceCalculator for each run type to
9
- # dial in the height of the curve. (See Runby::PaceCalculator)
7
+ # plotted on a graph. Then we use a radius divisor for the PaceData for each run type to
8
+ # dial in the height of the curve. (See RunbyPace::PaceData)
10
9
  # This method, #find_divisor, accepts a hash of "golden paces" for a run type along with
11
10
  # the number of seconds of allowable deviation from the golden pace. Then it proceeds
12
11
  # to brute force the divisor.
13
- # @param [GoldenPaceSet] golden_pace_set
12
+ # @param [Hash] golden_paces
14
13
  # @param [String] allowable_deviation
15
14
  # @return [decimal]
16
- def self.find_divisor(golden_pace_set, allowable_deviation = '00:01')
15
+ def self.find_divisor(golden_paces, allowable_deviation = '00:01')
16
+ _, first_pace = golden_paces.first
17
+ last_pace = golden_paces[:'42:00']
17
18
  viable_divisors = []
18
19
 
19
20
  (1.0..5.0).step(0.025) do |candidate_divisor|
20
21
  viable_divisor = nil
21
22
 
22
- golden_pace_set.each do |five_k, golden_pace|
23
- five_k_time = Runby::RunbyTime.new(five_k.to_s)
24
- pace_data = Runby::PaceCalculator.new(golden_pace_set, candidate_divisor)
23
+ golden_paces.each do |five_k, golden_pace|
24
+ five_k_time = RunbyPace::PaceTime.new(five_k.to_s)
25
+ pace_data = RunbyPace::PaceData.new(first_pace, last_pace, candidate_divisor)
25
26
  calculated_pace = pace_data.calc(five_k_time)
26
- unless calculated_pace.almost_equals?(golden_pace, allowable_deviation)
27
+ if !calculated_pace.almost_equals?(golden_pace, allowable_deviation)
27
28
  viable_divisor = nil
28
29
  break
29
30
  end
30
31
  viable_divisor = candidate_divisor
31
32
  end
32
33
 
33
- viable_divisors << viable_divisor unless viable_divisor.nil?
34
+ if viable_divisor != nil
35
+ viable_divisors << viable_divisor
36
+ end
34
37
  end
35
38
 
36
- unless viable_divisors.empty?
39
+ if viable_divisors.length > 0
37
40
  # puts viable_divisors
38
41
  midpoint = (viable_divisors.length - 1) / 2
39
42
  return viable_divisors[midpoint]
40
43
  end
41
44
  end
45
+
42
46
  end
43
47
  end
@@ -1,53 +1,31 @@
1
- # frozen_string_literal: true
1
+ module RunbyPace
2
2
 
3
- module Runby
4
3
  module RunTypes
5
- # Arguably one of the most important run types, the "long run" is harder than an "easy run", but easier than
6
- # a "distance run". It should remain conversational.
4
+
7
5
  class LongRun < RunType
8
- attr_reader :slow_pace_calculator, :fast_pace_calculator
6
+ attr_reader :slow_pace_data, :fast_pace_data
9
7
 
10
8
  def description
11
9
  'Long Run'
12
10
  end
13
11
 
14
- def explanation
15
- 'For many runners, the long run is the favorite run of the week. It is usually only ran once per week, and accounts for 20-25% of your weekly training volume. Remember that it\'s not a race. It should remain comfortable.'
16
- end
17
-
18
12
  def initialize
19
- @fast_pace_calculator = PaceCalculator.new(GoldenPaces.fast, 2.125)
20
- @slow_pace_calculator = PaceCalculator.new(GoldenPaces.slow, 1.55)
13
+ @fast_pace_data = PaceData.new(GoldenPaces::fast[:'14:00'], GoldenPaces::fast[:'42:00'], 2.125)
14
+ @slow_pace_data = PaceData.new(GoldenPaces::slow[:'14:00'], GoldenPaces::slow[:'42:00'], 1.55)
21
15
  end
22
16
 
23
- def lookup_pace(five_k_time, distance_units = :km)
24
- fast = @fast_pace_calculator.calc(five_k_time, distance_units)
25
- slow = @slow_pace_calculator.calc(five_k_time, distance_units)
17
+ def pace(five_k_time)
18
+ fast = @fast_pace_data.calc(five_k_time)
19
+ slow = @slow_pace_data.calc(five_k_time)
26
20
  PaceRange.new(fast, slow)
27
21
  end
28
22
 
29
- # Used in testing, contains hashes mapping 5K race times with the recommended pace-per-km for this run type.
30
23
  class GoldenPaces
31
24
  def self.fast
32
- GoldenPaceSet.new('14:00': '04:00',
33
- '15:00': '04:16',
34
- '20:00': '05:31',
35
- '25:00': '06:44',
36
- '30:00': '07:54',
37
- '35:00': '09:01',
38
- '40:00': '10:07',
39
- '42:00': '10:32')
25
+ { '14:00': '04:00', '15:00': '04:16', '20:00': '05:31', '25:00': '06:44', '30:00': '07:54', '35:00':'09:01', '40:00':'10:07', '42:00':'10:32'}
40
26
  end
41
-
42
27
  def self.slow
43
- GoldenPaceSet.new('14:00': '04:39',
44
- '15:00': '04:57',
45
- '20:00': '06:22',
46
- '25:00': '07:43',
47
- '30:00': '09:00',
48
- '35:00': '10:15',
49
- '40:00': '11:26',
50
- '42:00': '11:53')
28
+ { '14:00': '04:39', '15:00': '04:57', '20:00': '06:22', '25:00': '07:43', '30:00': '09:00', '35:00':'10:15', '40:00':'11:26', '42:00':'11:53'}
51
29
  end
52
30
  end
53
31
  end
@@ -1,18 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
- require 'fileutils'
4
- include FileUtils
5
-
6
- module Runby
7
-
8
- VERSION = begin
9
- path = './lib/runby_pace/version.g.rb'
10
- if File.exist? path
11
- load path
12
- Runby::GENERATED_VERSION
13
- else
14
- puts "\e[31m__TEXT__\e[0m".gsub('__TEXT__', 'Version number not set. Run "rake gen_version_number"')
15
- '0.0.0'
16
- end
17
- end
1
+ module RunbyPace
2
+ VERSION = "0.2.#{`git rev-list --count HEAD`}"
18
3
  end
data/runby_pace.gemspec CHANGED
@@ -5,15 +5,15 @@ require 'runby_pace/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'runby_pace'
8
- spec.version = Runby::VERSION
8
+ spec.version = RunbyPace::VERSION
9
9
  spec.authors = ['Ty Walls']
10
10
  spec.email = ['tygerbytes@users.noreply.github.com']
11
11
 
12
- spec.summary = 'Runby Pace is the core logic which simplifies the calculation of target paces used by track and distance runners.'
12
+ spec.summary = %q{Runby Pace is the core logic which simplifies the calculation of target paces used by track and distance runners.}
13
13
  spec.homepage = 'https://github.com/tygerbytes/runby-pace'
14
14
  spec.license = 'MIT'
15
15
 
16
- spec.metadata = { 'commit-hash' => `git log -n 1 --pretty=format:"%H"` }
16
+ spec.metadata = { 'commit-hash' => `git log -n 1 --pretty=format:"%H"`}
17
17
 
18
18
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
19
  spec.files += `git ls-files -z --other */all_run_types.g.rb`.split("\x0")
@@ -21,9 +21,10 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ['lib']
23
23
 
24
- spec.required_ruby_version = '>= 2.4.0'
24
+ spec.required_ruby_version = '>= 2.2.0'
25
25
 
26
26
  spec.add_development_dependency 'bundler', '~> 1.12'
27
27
  spec.add_development_dependency 'rake', '~> 10.0'
28
28
  spec.add_development_dependency 'rspec', '~> 3.0'
29
+
29
30
  end
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runby_pace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.50.111
4
+ version: 0.2.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ty Walls
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-06 00:00:00.000000000 Z
11
+ date: 2016-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.12'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.12'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
55
  description:
@@ -59,10 +59,9 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - ".gitignore"
63
- - ".rspec"
64
- - ".rubocop.yml"
65
- - ".travis.yml"
62
+ - .gitignore
63
+ - .rspec
64
+ - .travis.yml
66
65
  - Gemfile
67
66
  - Guardfile
68
67
  - LICENSE.txt
@@ -71,64 +70,42 @@ files:
71
70
  - bin/_guard-core
72
71
  - bin/console
73
72
  - bin/guard
74
- - bin/runbypace
75
73
  - bin/setup
76
74
  - lib/runby_pace.rb
77
- - lib/runby_pace/cli/cli.rb
78
- - lib/runby_pace/cli/config.rb
79
- - lib/runby_pace/distance.rb
80
- - lib/runby_pace/distance_unit.rb
81
- - lib/runby_pace/golden_pace_set.rb
82
- - lib/runby_pace/pace.rb
83
- - lib/runby_pace/pace_calculator.rb
75
+ - lib/runby_pace/pace_data.rb
84
76
  - lib/runby_pace/pace_range.rb
85
- - lib/runby_pace/run_math.rb
77
+ - lib/runby_pace/pace_time.rb
86
78
  - lib/runby_pace/run_type.rb
87
79
  - lib/runby_pace/run_types/all_run_types.g.rb
88
80
  - lib/runby_pace/run_types/all_run_types.template
89
- - lib/runby_pace/run_types/distance_run.rb
90
81
  - lib/runby_pace/run_types/easy_run.rb
91
- - lib/runby_pace/run_types/fast_tempo_run.rb
92
82
  - lib/runby_pace/run_types/find_divisor.rb
93
- - lib/runby_pace/run_types/five_kilometer_race_run.rb
94
83
  - lib/runby_pace/run_types/long_run.rb
95
- - lib/runby_pace/run_types/mile_race_run.rb
96
- - lib/runby_pace/run_types/slow_tempo_run.rb
97
- - lib/runby_pace/run_types/tempo_run.rb
98
- - lib/runby_pace/run_types/ten_kilometer_race_run.rb
99
- - lib/runby_pace/runby_range.rb
100
- - lib/runby_pace/runby_time.rb
101
- - lib/runby_pace/runby_time_parser.rb
102
- - lib/runby_pace/speed.rb
103
- - lib/runby_pace/speed_range.rb
104
- - lib/runby_pace/utility/parameter_sanitizer.rb
105
84
  - lib/runby_pace/version.rb
106
- - lib/runby_pace/version.seed
107
85
  - misc/rubymine.png
108
- - misc/runbypace_logo.png
109
86
  - runby_pace.gemspec
110
87
  homepage: https://github.com/tygerbytes/runby-pace
111
88
  licenses:
112
89
  - MIT
113
90
  metadata:
114
- commit-hash: c92a2ee6d44aba3feaedf8bb7661770c1c5d0299
91
+ commit-hash: 90c8a805cae7d6d0752403683b467916b1ee1d61
115
92
  post_install_message:
116
93
  rdoc_options: []
117
94
  require_paths:
118
95
  - lib
119
96
  required_ruby_version: !ruby/object:Gem::Requirement
120
97
  requirements:
121
- - - ">="
98
+ - - ! '>='
122
99
  - !ruby/object:Gem::Version
123
- version: 2.4.0
100
+ version: 2.2.0
124
101
  required_rubygems_version: !ruby/object:Gem::Requirement
125
102
  requirements:
126
- - - ">="
103
+ - - ! '>='
127
104
  - !ruby/object:Gem::Version
128
105
  version: '0'
129
106
  requirements: []
130
107
  rubyforge_project:
131
- rubygems_version: 2.7.3
108
+ rubygems_version: 2.4.5
132
109
  signing_key:
133
110
  specification_version: 4
134
111
  summary: Runby Pace is the core logic which simplifies the calculation of target paces
data/.rubocop.yml DELETED
@@ -1,10 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.4
3
- Exclude:
4
- - 'bin/**'
5
-
6
- Style/Encoding:
7
- Enabled: false
8
-
9
- Metrics/LineLength:
10
- Max: 120