strava-ruby-client 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/README.md +176 -15
  4. data/bin/strava-oauth-token.rb +47 -0
  5. data/lib/strava-ruby-client.rb +22 -1
  6. data/lib/strava/api/client.rb +150 -3
  7. data/lib/strava/api/cursor.rb +29 -0
  8. data/lib/strava/models/activity.rb +90 -4
  9. data/lib/strava/models/activity_zone.rb +13 -0
  10. data/lib/strava/models/athlete.rb +8 -0
  11. data/lib/strava/models/club.rb +26 -0
  12. data/lib/strava/models/comment.rb +12 -0
  13. data/lib/strava/models/gear.rb +11 -0
  14. data/lib/strava/models/lap.rb +26 -0
  15. data/lib/strava/models/map.rb +1 -0
  16. data/lib/strava/models/mixins/distance.rb +73 -0
  17. data/lib/strava/models/mixins/elevation.rb +46 -0
  18. data/lib/strava/models/mixins/time.rb +99 -0
  19. data/lib/strava/models/photo.rb +10 -0
  20. data/lib/strava/models/photos.rb +9 -0
  21. data/lib/strava/models/segment.rb +33 -0
  22. data/lib/strava/models/segment_effort.rb +24 -0
  23. data/lib/strava/models/similar_activities.rb +17 -0
  24. data/lib/strava/models/split.rb +29 -0
  25. data/lib/strava/models/timed_zone_range.rb +9 -0
  26. data/lib/strava/models/trend.rb +12 -0
  27. data/lib/strava/version.rb +1 -1
  28. metadata +35 -47
  29. data/.gitignore +0 -6
  30. data/.rspec +0 -2
  31. data/.rubocop.yml +0 -15
  32. data/.rubocop_todo.yml +0 -47
  33. data/.travis.yml +0 -9
  34. data/CONTRIBUTING.md +0 -125
  35. data/Dangerfile +0 -2
  36. data/Gemfile +0 -15
  37. data/RELEASING.md +0 -61
  38. data/Rakefile +0 -17
  39. data/bin/oauth-token.rb +0 -28
  40. data/spec/fixtures/strava/client_athlete.yml +0 -59
  41. data/spec/fixtures/strava/client_athlete_activities.yml +0 -121
  42. data/spec/fixtures/strava/oauth_token_authorization_code.yml +0 -53
  43. data/spec/fixtures/strava/oauth_token_invalid_client.yml +0 -50
  44. data/spec/fixtures/strava/oauth_token_invalid_code.yml +0 -50
  45. data/spec/fixtures/strava/oauth_token_refresh_token.yml +0 -52
  46. data/spec/spec_helper.rb +0 -10
  47. data/spec/strava/api/client_spec.rb +0 -36
  48. data/spec/strava/api/config_spec.rb +0 -22
  49. data/spec/strava/oauth/client_spec.rb +0 -120
  50. data/spec/strava/oauth/config_spec.rb +0 -24
  51. data/spec/strava/version_spec.rb +0 -7
  52. data/spec/strava/web/client_spec.rb +0 -9
  53. data/spec/strava/web/config_spec.rb +0 -4
  54. data/spec/support/shared/it_behaves_like_web_client.rb +0 -131
  55. data/spec/support/vcr.rb +0 -12
  56. data/strava-ruby-client.gemspec +0 -21
@@ -0,0 +1,10 @@
1
+ module Strava
2
+ module Models
3
+ class Photo < Model
4
+ property 'id'
5
+ property 'unique_id'
6
+ property 'urls'
7
+ property 'source'
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ module Strava
2
+ module Models
3
+ class Photos < Model
4
+ property 'primary', transform_with: ->(v) { Strava::Models::Photo.new(v) }
5
+ property 'use_primary_photo'
6
+ property 'count'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,33 @@
1
+ module Strava
2
+ module Models
3
+ class Segment < Model
4
+ include Mixins::Distance
5
+
6
+ property 'id'
7
+ property 'resource_state'
8
+ property 'name'
9
+ property 'maximum_grade'
10
+ property 'elevation_high'
11
+ property 'elevation_low'
12
+ property 'activity_type'
13
+ property 'average_grade'
14
+ property 'climb_category'
15
+ property 'city'
16
+ property 'state'
17
+ property 'country'
18
+ property 'start_latlng'
19
+ property 'end_latlng'
20
+ property 'start_latitude'
21
+ property 'start_longitude'
22
+ property 'end_latitude'
23
+ property 'end_longitude'
24
+ property 'private'
25
+ property 'hazardous'
26
+ property 'starred'
27
+
28
+ def units
29
+ :metric
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,24 @@
1
+ module Strava
2
+ module Models
3
+ class SegmentEffort < Model
4
+ include Mixins::Time
5
+
6
+ property 'id'
7
+ property 'resource_state'
8
+ property 'name'
9
+ property 'activity', transform_with: ->(v) { Strava::Models::Activity.new(v) }
10
+ property 'athlete', transform_with: ->(v) { Strava::Models::Athlete.new(v) }
11
+ property 'start_date', transform_with: ->(v) { Time.parse(v) }
12
+ property 'start_date_local', transform_with: ->(v) { Time.parse(v) }
13
+ property 'distance'
14
+ property 'start_index'
15
+ property 'end_index'
16
+ property 'average_heartrate'
17
+ property 'max_heartrate'
18
+ property 'segment', transform_with: ->(v) { Strava::Models::Segment.new(v) }
19
+ property 'achievements'
20
+ property 'hidden'
21
+ property 'pr_rank'
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,17 @@
1
+ module Strava
2
+ module Models
3
+ class SimilarActivities < Model
4
+ property 'average_speed'
5
+ property 'resource_state'
6
+ property 'effort_count'
7
+ property 'frequency_milestone'
8
+ property 'max_average_speed'
9
+ property 'mid_average_speed'
10
+ property 'min_average_speed'
11
+ property 'mid_speed'
12
+ property 'min_speed'
13
+ property 'speeds'
14
+ property 'trend', transform_with: ->(v) { Strava::Models::Trend.new(v) }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,29 @@
1
+ module Strava
2
+ module Models
3
+ class Split < Model
4
+ include Mixins::Distance
5
+ include Mixins::Time
6
+ include Mixins::Elevation
7
+
8
+ property 'elevation_difference'
9
+ property 'total_elevation_gain', from: 'elevation_difference'
10
+ property 'split'
11
+ property 'average_heartrate'
12
+ property 'pace_zone'
13
+
14
+ class Standard < Split
15
+ private
16
+
17
+ def units
18
+ :imperial
19
+ end
20
+ end
21
+
22
+ class Metric < Split
23
+ def units
24
+ :metric
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,9 @@
1
+ module Strava
2
+ module Models
3
+ class TimedZoneRange < Model
4
+ property 'max'
5
+ property 'min'
6
+ property 'time'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ module Strava
2
+ module Models
3
+ class Trend < Model
4
+ property 'speeds'
5
+ property 'current_activity_index'
6
+ property 'min_speed'
7
+ property 'mid_speed'
8
+ property 'max_speed'
9
+ property 'direction'
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module Strava
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strava-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-23 00:00:00.000000000 Z
11
+ date: 2018-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: faraday
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,30 +72,37 @@ executables: []
58
72
  extensions: []
59
73
  extra_rdoc_files: []
60
74
  files:
61
- - ".gitignore"
62
- - ".rspec"
63
- - ".rubocop.yml"
64
- - ".rubocop_todo.yml"
65
- - ".travis.yml"
66
75
  - CHANGELOG.md
67
- - CONTRIBUTING.md
68
- - Dangerfile
69
- - Gemfile
70
76
  - LICENSE.md
71
77
  - README.md
72
- - RELEASING.md
73
- - Rakefile
74
- - bin/oauth-token.rb
78
+ - bin/strava-oauth-token.rb
75
79
  - lib/strava-ruby-client.rb
76
80
  - lib/strava/api/client.rb
77
81
  - lib/strava/api/config.rb
82
+ - lib/strava/api/cursor.rb
78
83
  - lib/strava/errors/fault.rb
79
84
  - lib/strava/logger.rb
80
85
  - lib/strava/models/activity.rb
86
+ - lib/strava/models/activity_zone.rb
81
87
  - lib/strava/models/athlete.rb
88
+ - lib/strava/models/club.rb
89
+ - lib/strava/models/comment.rb
90
+ - lib/strava/models/gear.rb
91
+ - lib/strava/models/lap.rb
82
92
  - lib/strava/models/map.rb
93
+ - lib/strava/models/mixins/distance.rb
94
+ - lib/strava/models/mixins/elevation.rb
95
+ - lib/strava/models/mixins/time.rb
83
96
  - lib/strava/models/model.rb
97
+ - lib/strava/models/photo.rb
98
+ - lib/strava/models/photos.rb
99
+ - lib/strava/models/segment.rb
100
+ - lib/strava/models/segment_effort.rb
101
+ - lib/strava/models/similar_activities.rb
102
+ - lib/strava/models/split.rb
103
+ - lib/strava/models/timed_zone_range.rb
84
104
  - lib/strava/models/token.rb
105
+ - lib/strava/models/trend.rb
85
106
  - lib/strava/oauth/client.rb
86
107
  - lib/strava/oauth/config.rb
87
108
  - lib/strava/version.rb
@@ -90,23 +111,6 @@ files:
90
111
  - lib/strava/web/connection.rb
91
112
  - lib/strava/web/raise_error.rb
92
113
  - lib/strava/web/request.rb
93
- - spec/fixtures/strava/client_athlete.yml
94
- - spec/fixtures/strava/client_athlete_activities.yml
95
- - spec/fixtures/strava/oauth_token_authorization_code.yml
96
- - spec/fixtures/strava/oauth_token_invalid_client.yml
97
- - spec/fixtures/strava/oauth_token_invalid_code.yml
98
- - spec/fixtures/strava/oauth_token_refresh_token.yml
99
- - spec/spec_helper.rb
100
- - spec/strava/api/client_spec.rb
101
- - spec/strava/api/config_spec.rb
102
- - spec/strava/oauth/client_spec.rb
103
- - spec/strava/oauth/config_spec.rb
104
- - spec/strava/version_spec.rb
105
- - spec/strava/web/client_spec.rb
106
- - spec/strava/web/config_spec.rb
107
- - spec/support/shared/it_behaves_like_web_client.rb
108
- - spec/support/vcr.rb
109
- - strava-ruby-client.gemspec
110
114
  homepage: http://github.com/dblock/strava-ruby-client
111
115
  licenses:
112
116
  - MIT
@@ -131,20 +135,4 @@ rubygems_version: 2.7.6
131
135
  signing_key:
132
136
  specification_version: 4
133
137
  summary: Strava API Ruby client.
134
- test_files:
135
- - spec/fixtures/strava/client_athlete.yml
136
- - spec/fixtures/strava/client_athlete_activities.yml
137
- - spec/fixtures/strava/oauth_token_authorization_code.yml
138
- - spec/fixtures/strava/oauth_token_invalid_client.yml
139
- - spec/fixtures/strava/oauth_token_invalid_code.yml
140
- - spec/fixtures/strava/oauth_token_refresh_token.yml
141
- - spec/spec_helper.rb
142
- - spec/strava/api/client_spec.rb
143
- - spec/strava/api/config_spec.rb
144
- - spec/strava/oauth/client_spec.rb
145
- - spec/strava/oauth/config_spec.rb
146
- - spec/strava/version_spec.rb
147
- - spec/strava/web/client_spec.rb
148
- - spec/strava/web/config_spec.rb
149
- - spec/support/shared/it_behaves_like_web_client.rb
150
- - spec/support/vcr.rb
138
+ test_files: []
data/.gitignore DELETED
@@ -1,6 +0,0 @@
1
- .env
2
- pkg
3
- Gemfile.lock
4
- .DS_Store
5
- .bundle
6
- .idea
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color
@@ -1,15 +0,0 @@
1
- AllCops:
2
- Exclude:
3
- - vendor/**/*
4
-
5
- Naming/MethodName:
6
- Enabled: false
7
-
8
- Naming/FileName:
9
- Exclude:
10
- - 'lib/strava-ruby-client.rb'
11
-
12
- Style/ModuleFunction:
13
- EnforcedStyle: extend_self
14
-
15
- inherit_from: .rubocop_todo.yml
@@ -1,47 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2018-11-23 11:26:24 -0500 using RuboCop version 0.60.0.
4
- # The point is for the user to remove these configuration records
5
- # one by one as the offenses are removed from the code base.
6
- # Note that changes in the inspected code, or installation of new
7
- # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 1
10
- Metrics/AbcSize:
11
- Max: 30
12
-
13
- # Offense count: 7
14
- # Configuration parameters: CountComments, ExcludedMethods.
15
- # ExcludedMethods: refine
16
- Metrics/BlockLength:
17
- Max: 127
18
-
19
- # Offense count: 1
20
- Metrics/CyclomaticComplexity:
21
- Max: 9
22
-
23
- # Offense count: 2
24
- # Configuration parameters: CountComments, ExcludedMethods.
25
- Metrics/MethodLength:
26
- Max: 18
27
-
28
- # Offense count: 1
29
- Metrics/PerceivedComplexity:
30
- Max: 9
31
-
32
- # Offense count: 1
33
- # Configuration parameters: EnforcedStyleForLeadingUnderscores.
34
- # SupportedStylesForLeadingUnderscores: disallowed, required, optional
35
- Naming/MemoizedInstanceVariableName:
36
- Exclude:
37
- - 'lib/strava/logger.rb'
38
-
39
- # Offense count: 19
40
- Style/Documentation:
41
- Enabled: false
42
-
43
- # Offense count: 25
44
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
45
- # URISchemes: http, https
46
- Metrics/LineLength:
47
- Max: 112
@@ -1,9 +0,0 @@
1
- language: ruby
2
-
3
- cache: bundler
4
-
5
- rvm:
6
- - 2.5.1
7
-
8
- before_script:
9
- - bundle exec danger
@@ -1,125 +0,0 @@
1
- # Contributing to Strava-Ruby-Client
2
-
3
- This project is work of [many contributors](https://github.com/dblock/strava-ruby-client/graphs/contributors).
4
-
5
- You're encouraged to submit [pull requests](https://github.com/dblock/strava-ruby-client/pulls), [propose features and discuss issues](https://github.com/dblock/strava-ruby-client/issues).
6
-
7
- In the examples below, substitute your Github username for `contributor` in URLs.
8
-
9
- ### Fork the Project
10
-
11
- Fork the [project on Github](https://github.com/dblock/strava-ruby-client) and check out your copy.
12
-
13
- ```
14
- git clone https://github.com/contributor/strava-ruby-client.git
15
- cd strava-ruby-client
16
- git remote add upstream https://github.com/dblock/strava-ruby-client.git
17
- ```
18
-
19
- ### Bundle Install and Test
20
-
21
- Ensure that you can build the project and run tests.
22
-
23
- ```
24
- bundle install
25
- bundle exec rake
26
- ```
27
-
28
- ## Contribute Code
29
-
30
- ### Create a Topic Branch
31
-
32
- Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
33
-
34
- ```
35
- git checkout master
36
- git pull upstream master
37
- git checkout -b my-feature-branch
38
- ```
39
-
40
- ### Write Tests
41
-
42
- Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add tests to [spec](spec).
43
-
44
- We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
45
-
46
- ### Write Code
47
-
48
- Implement your feature or bug fix.
49
-
50
- Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop). Run `bundle exec rubocop` and fix any style issues highlighted, auto-correct issues when possible with `bundle exec rubocop -a`. To silence generally ingored issues, including line lengths or code complexity metrics, run `bundle exec rubocop --auto-gen-config`.
51
-
52
- Make sure that `bundle exec rake` completes without errors.
53
-
54
- ### Write Documentation
55
-
56
- Document any external behavior in the [README](README.md).
57
-
58
- ### Update Changelog
59
-
60
- Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Don't remove *Your contribution here*.
61
-
62
- Make it look like every other line, including a link to the issue being fixed, your name and link to your Github account.
63
-
64
- ### Commit Changes
65
-
66
- Make sure git knows your name and email address:
67
-
68
- ```
69
- git config --global user.name "Your Name"
70
- git config --global user.email "contributor@example.com"
71
- ```
72
-
73
- Writing good commit logs is important. A commit log should describe what changed and why.
74
-
75
- ```
76
- git add ...
77
- git commit
78
- ```
79
-
80
- ### Push
81
-
82
- ```
83
- git push origin my-feature-branch
84
- ```
85
-
86
- ### Make a Pull Request
87
-
88
- Go to https://github.com/contributor/strava-ruby-client and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
89
-
90
- ### Update CHANGELOG Again
91
-
92
- Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
93
-
94
- ```
95
- * [#123](https://github.com/dblock/strava-ruby-client/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
96
- ```
97
-
98
- Amend your previous commit and force push the changes.
99
-
100
- ```
101
- git commit --amend
102
- git push origin my-feature-branch -f
103
- ```
104
-
105
- ### Rebase
106
-
107
- If you've been working on a change for a while, rebase with upstream/master.
108
-
109
- ```
110
- git fetch upstream
111
- git rebase upstream/master
112
- git push origin my-feature-branch -f
113
- ```
114
-
115
- ### Check on Your Pull Request
116
-
117
- Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
118
-
119
- ### Be Patient
120
-
121
- It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
122
-
123
- ## Thank You
124
-
125
- Please do know that we really appreciate and value your time and work. We love you, really.