piste_pal 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/lib/piste_pal/day_pass.rb +8 -1
- data/lib/piste_pal/season_pass.rb +16 -1
- data/lib/piste_pal/version.rb +1 -1
- data/piste_pal.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81502bdf7d7c411845d4e07a10e270d46fba652d7668d0b6a1d90153898c2b94
|
4
|
+
data.tar.gz: 2da58aba2b8769421666d4f4116a7e61192a9fe0f057f2030940e86114b0a0fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a81f84c7b0acdfc34857c360e2a68755884788bf121603c5c65abfb9ddb5bfc446d8861eba73f3fc6c106796f96791ea745382a4d84289a0dbcb3e244e6c399
|
7
|
+
data.tar.gz: b3b269adfac6f6448879444f33a70dada54866eb02bf2c3d1aa41d23cda34ceb5cb033543fb8d202036549aa18663f8f9b3a41b9dd2a17551773f282fac5cca3
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# PistePal
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/piste_pal.svg)](https://badge.fury.io/rb/piste_pal)
|
4
|
+
|
3
5
|
Fill your time off the slopes thinking about them. This gem takes .gpx files from popular activity tracking apps and turns them into fun stats.
|
4
6
|
|
5
7
|
The code can be accessed at a high level by "purchasing" either Day Passes or Season Passes, but most of the functionality is modularized to allow you access to the stats you want.
|
data/lib/piste_pal/day_pass.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module PistePal
|
2
2
|
class DayPass
|
3
|
-
attr_accessor :resort, :date, :trackpoints, :maximum_speed, :peak_altitude, :vertical, :distance, :tallest_run, :longest_run, :runs, :lifts
|
3
|
+
attr_accessor :resort, :date, :trackpoints, :maximum_speed, :peak_altitude, :vertical, :distance, :tallest_run, :longest_run, :runs, :lifts, :total_hours
|
4
4
|
|
5
5
|
def self.purchase file_content
|
6
6
|
new(file_content: file_content)
|
@@ -95,6 +95,13 @@ module PistePal
|
|
95
95
|
@distance = PistePal::DataServices::Distance.call(trackpoints: @runs)
|
96
96
|
@vertical = PistePal::DataServices::Vertical.call(trackpoints: @runs)
|
97
97
|
@tallest_run, @longest_run = PistePal::DataServices::TallestAndLongestRun.call(runs: @runs)
|
98
|
+
@total_hours = calculate_total_hours
|
99
|
+
end
|
100
|
+
|
101
|
+
def calculate_total_hours
|
102
|
+
first = @trackpoints.first.time
|
103
|
+
last = @trackpoints.last.time
|
104
|
+
(Time.parse(last) - Time.parse(first)) / 3600
|
98
105
|
end
|
99
106
|
end
|
100
107
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module PistePal
|
2
2
|
class SeasonPass
|
3
|
-
attr_accessor :days, :resorts, :runs, :vertical, :distance
|
3
|
+
attr_accessor :days, :resorts, :runs, :vertical, :distance, :maximum_speed, :total_hours
|
4
4
|
|
5
5
|
def self.purchase files
|
6
6
|
new(files: files)
|
@@ -29,6 +29,21 @@ module PistePal
|
|
29
29
|
:value => @days.map {|day| day.distance[:value] }.reduce(0, :+),
|
30
30
|
:unit => @days.first.distance[:unit]
|
31
31
|
}
|
32
|
+
|
33
|
+
@maximum_speed = generate_maximum_speed
|
34
|
+
@total_hours = generate_total_hours
|
35
|
+
end
|
36
|
+
|
37
|
+
def generate_maximum_speed
|
38
|
+
maximum_speed = nil
|
39
|
+
@days.each do |day|
|
40
|
+
maximum_speed = day.maximum_speed if maximum_speed.nil? || day.maximum_speed[:value] > maximum_speed[:value]
|
41
|
+
end
|
42
|
+
return maximum_speed
|
43
|
+
end
|
44
|
+
|
45
|
+
def generate_total_hours
|
46
|
+
@days.map {|day| day.total_hours }.reduce(0, :+)
|
32
47
|
end
|
33
48
|
end
|
34
49
|
end
|
data/lib/piste_pal/version.rb
CHANGED
data/piste_pal.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency "rake", "~> 10.0"
|
29
29
|
spec.add_development_dependency "rspec", "~> 3.0"
|
30
30
|
spec.add_development_dependency "byebug", "~> 11.0"
|
31
|
-
spec.add_dependency "nokogiri", "
|
31
|
+
spec.add_dependency "nokogiri", "1.10.3"
|
32
32
|
spec.add_dependency "rake", "~> 10.0"
|
33
33
|
spec.add_dependency "vincenty_distance", "~> 1.0.0"
|
34
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: piste_pal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Menden
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: nokogiri
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 1.10.3
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 1.10.3
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|