runby_pace 0.2.50 → 0.2.50.111

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +10 -0
  3. data/.travis.yml +9 -2
  4. data/Gemfile +4 -0
  5. data/README.md +16 -5
  6. data/Rakefile +40 -6
  7. data/bin/_guard-core +17 -16
  8. data/bin/guard +17 -16
  9. data/bin/runbypace +15 -0
  10. data/lib/runby_pace/cli/cli.rb +127 -0
  11. data/lib/runby_pace/cli/config.rb +82 -0
  12. data/lib/runby_pace/distance.rb +135 -0
  13. data/lib/runby_pace/distance_unit.rb +89 -0
  14. data/lib/runby_pace/golden_pace_set.rb +50 -0
  15. data/lib/runby_pace/pace.rb +152 -0
  16. data/lib/runby_pace/{pace_data.rb → pace_calculator.rb} +29 -13
  17. data/lib/runby_pace/pace_range.rb +27 -9
  18. data/lib/runby_pace/run_math.rb +14 -0
  19. data/lib/runby_pace/run_type.rb +12 -4
  20. data/lib/runby_pace/run_types/all_run_types.g.rb +14 -12
  21. data/lib/runby_pace/run_types/all_run_types.template +6 -4
  22. data/lib/runby_pace/run_types/distance_run.rb +55 -0
  23. data/lib/runby_pace/run_types/easy_run.rb +31 -10
  24. data/lib/runby_pace/run_types/fast_tempo_run.rb +23 -0
  25. data/lib/runby_pace/run_types/find_divisor.rb +13 -17
  26. data/lib/runby_pace/run_types/five_kilometer_race_run.rb +22 -0
  27. data/lib/runby_pace/run_types/long_run.rb +32 -10
  28. data/lib/runby_pace/run_types/mile_race_run.rb +24 -0
  29. data/lib/runby_pace/run_types/slow_tempo_run.rb +22 -0
  30. data/lib/runby_pace/run_types/tempo_run.rb +54 -0
  31. data/lib/runby_pace/run_types/ten_kilometer_race_run.rb +23 -0
  32. data/lib/runby_pace/runby_range.rb +22 -0
  33. data/lib/runby_pace/runby_time.rb +138 -0
  34. data/lib/runby_pace/runby_time_parser.rb +80 -0
  35. data/lib/runby_pace/speed.rb +97 -0
  36. data/lib/runby_pace/speed_range.rb +30 -0
  37. data/lib/runby_pace/utility/parameter_sanitizer.rb +29 -0
  38. data/lib/runby_pace/version.rb +17 -2
  39. data/lib/runby_pace/version.seed +5 -0
  40. data/lib/runby_pace.rb +4 -1
  41. data/misc/runbypace_logo.png +0 -0
  42. data/runby_pace.gemspec +5 -6
  43. metadata +32 -9
  44. data/lib/runby_pace/pace_time.rb +0 -110
@@ -1,3 +1,18 @@
1
- module RunbyPace
2
- VERSION = "0.2.#{`git rev-list --count HEAD`}"
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
3
18
  end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Runby
4
+ GENERATED_VERSION = '__VERSION__'
5
+ end
data/lib/runby_pace.rb CHANGED
@@ -1,7 +1,10 @@
1
1
 
2
2
  require 'runby_pace/version'
3
3
  Dir[File.dirname(__FILE__) + '/runby_pace/*.rb'].each { |file| require file }
4
+ Dir[File.dirname(__FILE__) + '/runby_pace/cli/*.rb'].each { |file| require file }
4
5
  Dir[File.dirname(__FILE__) + '/runby_pace/run_types/*.rb'].each { |file| require file }
6
+ Dir[File.dirname(__FILE__) + '/runby_pace/utility/*.rb'].each { |file| require file }
5
7
 
6
- module RunbyPace
8
+ # The main module
9
+ module Runby
7
10
  end
Binary file
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 = RunbyPace::VERSION
8
+ spec.version = Runby::VERSION
9
9
  spec.authors = ['Ty Walls']
10
10
  spec.email = ['tygerbytes@users.noreply.github.com']
11
11
 
12
- spec.summary = %q{Runby Pace is the core logic which simplifies the calculation of target paces used by track and distance runners.}
12
+ spec.summary = '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,10 +21,9 @@ 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.2.0'
24
+ spec.required_ruby_version = '>= 2.4.0'
25
25
 
26
- spec.add_development_dependency 'bundler', '~> 1.11'
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
-
30
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runby_pace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.50
4
+ version: 0.2.50.111
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ty Walls
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-11 00:00:00.000000000 Z
11
+ date: 2017-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.11'
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
- version: '1.11'
26
+ version: '1.12'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -61,6 +61,7 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
63
  - ".rspec"
64
+ - ".rubocop.yml"
64
65
  - ".travis.yml"
65
66
  - Gemfile
66
67
  - Guardfile
@@ -70,25 +71,47 @@ files:
70
71
  - bin/_guard-core
71
72
  - bin/console
72
73
  - bin/guard
74
+ - bin/runbypace
73
75
  - bin/setup
74
76
  - lib/runby_pace.rb
75
- - lib/runby_pace/pace_data.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
76
84
  - lib/runby_pace/pace_range.rb
77
- - lib/runby_pace/pace_time.rb
85
+ - lib/runby_pace/run_math.rb
78
86
  - lib/runby_pace/run_type.rb
79
87
  - lib/runby_pace/run_types/all_run_types.g.rb
80
88
  - lib/runby_pace/run_types/all_run_types.template
89
+ - lib/runby_pace/run_types/distance_run.rb
81
90
  - lib/runby_pace/run_types/easy_run.rb
91
+ - lib/runby_pace/run_types/fast_tempo_run.rb
82
92
  - lib/runby_pace/run_types/find_divisor.rb
93
+ - lib/runby_pace/run_types/five_kilometer_race_run.rb
83
94
  - 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
84
105
  - lib/runby_pace/version.rb
106
+ - lib/runby_pace/version.seed
85
107
  - misc/rubymine.png
108
+ - misc/runbypace_logo.png
86
109
  - runby_pace.gemspec
87
110
  homepage: https://github.com/tygerbytes/runby-pace
88
111
  licenses:
89
112
  - MIT
90
113
  metadata:
91
- commit-hash: 0826d8e9f04e8fa9166717fc4639c719049e2ad7
114
+ commit-hash: c92a2ee6d44aba3feaedf8bb7661770c1c5d0299
92
115
  post_install_message:
93
116
  rdoc_options: []
94
117
  require_paths:
@@ -97,7 +120,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
97
120
  requirements:
98
121
  - - ">="
99
122
  - !ruby/object:Gem::Version
100
- version: 2.2.0
123
+ version: 2.4.0
101
124
  required_rubygems_version: !ruby/object:Gem::Requirement
102
125
  requirements:
103
126
  - - ">="
@@ -105,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
128
  version: '0'
106
129
  requirements: []
107
130
  rubyforge_project:
108
- rubygems_version: 2.4.5.1
131
+ rubygems_version: 2.7.3
109
132
  signing_key:
110
133
  specification_version: 4
111
134
  summary: Runby Pace is the core logic which simplifies the calculation of target paces
@@ -1,110 +0,0 @@
1
- module RunbyPace
2
-
3
- class PaceTime
4
- attr_reader :time_s, :minutes_part, :seconds_part
5
-
6
- def initialize(time)
7
- if time.is_a?(String) || time.is_a?(Symbol)
8
- init_from_string(time)
9
- elsif time.is_a?(PaceTime)
10
- init_from_clone(time)
11
- end
12
- end
13
-
14
- # @param [numeric] total_seconds
15
- def self.from_seconds(total_seconds)
16
- minutes = total_seconds.abs.to_i / 60
17
- seconds = total_seconds.abs.to_i % 60
18
- PaceTime.new("#{'%02d' % minutes}:#{'%02d' % seconds}")
19
- end
20
-
21
- # @param [numeric] total_minutes
22
- def self.from_minutes(total_minutes)
23
- self.from_seconds(total_minutes * 60.0)
24
- end
25
-
26
- def to_s
27
- @time_s
28
- end
29
-
30
- def total_seconds
31
- @minutes_part * 60 + @seconds_part
32
- end
33
-
34
- def total_minutes
35
- @minutes_part + (@seconds_part / 60.0)
36
- end
37
-
38
- # @param [PaceTime] value
39
- def -(value)
40
- if value.is_a?(PaceTime)
41
- PaceTime.from_seconds(total_seconds - value.total_seconds)
42
- end
43
- end
44
-
45
- # @param [PaceTime] value
46
- def +(value)
47
- if value.is_a?(PaceTime)
48
- PaceTime.from_seconds(total_seconds + value.total_seconds)
49
- end
50
- end
51
-
52
- def ==(value)
53
- if value.is_a?(PaceTime)
54
- total_seconds == value.total_seconds
55
- elsif value.is_a?(String)
56
- @time_s == value
57
- end
58
- end
59
-
60
- def almost_equals?(other_time, tolerance_time = '00:01')
61
- if other_time.is_a?(String)
62
- other_time = PaceTime.new(other_time)
63
- end
64
- tolerance = PaceTime.new(tolerance_time)
65
- self >= (other_time - tolerance) && self <= (other_time + tolerance)
66
- end
67
-
68
- def >(value)
69
- if value.is_a?(PaceTime)
70
- total_seconds > value.total_seconds
71
- end
72
- end
73
-
74
- def >=(value)
75
- if value.is_a?(PaceTime)
76
- total_seconds >= value.total_seconds
77
- end
78
- end
79
-
80
- def <(value)
81
- if value.is_a?(PaceTime)
82
- total_seconds < value.total_seconds
83
- end
84
- end
85
-
86
- def <=(value)
87
- if value.is_a?(PaceTime)
88
- total_seconds <= value.total_seconds
89
- end
90
- end
91
-
92
- private
93
-
94
- def init_from_string(time)
95
- raise 'Invalid time format' if !time.match(/(-)?\d\d:\d\d/)
96
- @time_s = time.to_s
97
- parts = time.to_s.split(':')
98
- @minutes_part = parts[0].to_i
99
- @seconds_part = parts[1].to_i
100
- raise 'Seconds must be less than 60' if @seconds_part.abs > 59
101
- end
102
-
103
- # @param [PaceTime] time
104
- def init_from_clone(time)
105
- @time_s = time.time_s
106
- @minutes_part = time.minutes_part
107
- @seconds_part = time.seconds_part
108
- end
109
- end
110
- end