smashrun-ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1678e0fac995491554be1b8037fd658b2e56f389
4
+ data.tar.gz: 48103be8343c9358f940a7a2d38c41e0835da6b6
5
+ SHA512:
6
+ metadata.gz: f452739f5b355ca4bf011e70ec9a7d4baa869041eec3451bc948b7f2021e2e8fc7e6ce7a4d010c2b990a66f8c5fdc0c9423e5a3cb1298c7b7de23195380738cf
7
+ data.tar.gz: 27819ca6ed56593f3f8a4991dd28350ff0efe466a3d82c4482acb2e1d5b6f8d848b48f0621df2bf2d7114c9b5c240fc2dae7927db78a7d2f398ff890309d8605
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "https://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ source 'https://rubygems.org'
7
+ gem 'oauth2', '~> 1.4.0'
8
+ gem 'oj', '~> 3.3.5'
9
+
10
+ # Add dependencies to develop your gem here.
11
+ # Include everything needed to run rake, tests, features, etc.
12
+ group :development do
13
+ gem "rdoc", "~> 3.12"
14
+ gem "bundler", "~> 1.0"
15
+ gem "juwelier", "~> 2.1.0"
16
+ gem "simplecov", ">= 0"
17
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,71 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ addressable (2.4.0)
5
+ builder (3.2.3)
6
+ descendants_tracker (0.0.4)
7
+ thread_safe (~> 0.3, >= 0.3.1)
8
+ docile (1.1.5)
9
+ faraday (0.9.2)
10
+ multipart-post (>= 1.2, < 3)
11
+ git (1.3.0)
12
+ github_api (0.17.0)
13
+ addressable (~> 2.4.0)
14
+ descendants_tracker (~> 0.0.4)
15
+ faraday (~> 0.8, < 0.10)
16
+ hashie (>= 3.4)
17
+ mime-types (>= 1.16, < 3.0)
18
+ oauth2 (~> 1.0)
19
+ hashie (3.5.6)
20
+ highline (1.7.8)
21
+ json (1.8.6)
22
+ juwelier (2.1.3)
23
+ builder
24
+ bundler (>= 1.13)
25
+ git (>= 1.2.5)
26
+ github_api
27
+ highline (>= 1.6.15)
28
+ nokogiri (>= 1.5.10)
29
+ rake
30
+ rdoc
31
+ semver
32
+ jwt (1.5.6)
33
+ mime-types (2.99.3)
34
+ mini_portile2 (2.3.0)
35
+ multi_json (1.12.2)
36
+ multi_xml (0.6.0)
37
+ multipart-post (2.0.0)
38
+ nokogiri (1.8.1)
39
+ mini_portile2 (~> 2.3.0)
40
+ oauth2 (1.4.0)
41
+ faraday (>= 0.8, < 0.13)
42
+ jwt (~> 1.0)
43
+ multi_json (~> 1.3)
44
+ multi_xml (~> 0.5)
45
+ rack (>= 1.2, < 3)
46
+ oj (3.3.6)
47
+ rack (2.0.3)
48
+ rake (12.1.0)
49
+ rdoc (3.12.2)
50
+ json (~> 1.4)
51
+ semver (1.0.1)
52
+ simplecov (0.15.1)
53
+ docile (~> 1.1.0)
54
+ json (>= 1.8, < 3)
55
+ simplecov-html (~> 0.10.0)
56
+ simplecov-html (0.10.2)
57
+ thread_safe (0.3.6)
58
+
59
+ PLATFORMS
60
+ ruby
61
+
62
+ DEPENDENCIES
63
+ bundler (~> 1.0)
64
+ juwelier (~> 2.1.0)
65
+ oauth2 (~> 1.4.0)
66
+ oj (~> 3.3.5)
67
+ rdoc (~> 3.12)
68
+ simplecov
69
+
70
+ BUNDLED WITH
71
+ 1.13.7
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2017 Naveed Ahmad
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = smashrun
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to smashrun
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2017 Naveed Ahmad. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+ require 'juwelier'
14
+ Juwelier::Tasks.new do |gem|
15
+ # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
16
+ gem.name = "smashrun-ruby"
17
+ gem.homepage = "http://github.com/naveed-ahmad/smashrun"
18
+ gem.license = "MIT"
19
+ gem.summary = "Ruby gem for Smashrun api"
20
+ gem.description = gem.summary
21
+ gem.email = "naveedahmada036@gmail.com"
22
+ gem.authors = ["Naveed Ahmad"]
23
+
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Juwelier::RubygemsDotOrgTasks.new
27
+ require 'rake/testtask'
28
+ Rake::TestTask.new(:test) do |test|
29
+ test.libs << 'lib' << 'test'
30
+ test.pattern = 'test/**/test_*.rb'
31
+ test.verbose = true
32
+ end
33
+
34
+ desc "Code coverage detail"
35
+ task :simplecov do
36
+ ENV['COVERAGE'] = "true"
37
+ Rake::Task['test'].execute
38
+ end
39
+
40
+ task :default => :test
41
+
42
+ require 'rdoc/task'
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "smashrun-ruby #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/lib/smashrun.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'oauth2'
2
+ require 'oj'
3
+
4
+ require 'smashrun/configuration'
5
+ require 'smashrun/client'
6
+
7
+ module Smashrun
8
+ extend Configuration
9
+ end
@@ -0,0 +1,72 @@
1
+ module Smashrun
2
+ class Client
3
+ OAUTH_URLS = { site: 'https://api.smashrun.com',
4
+ authorize_url: 'https://secure.smashrun.com/oauth2/authenticate',
5
+ token_url: 'https://secure.smashrun.com/oauth2/token'
6
+ }
7
+
8
+ def initialize(access_token)
9
+ client = OAuth2::Client.new(client_id, client_secret, OAUTH_URLS)
10
+
11
+ @token = OAuth2::AccessToken.new(client, access_token)
12
+ end
13
+
14
+ def get_refresh_token(token)
15
+ @token.refresh_token = token
16
+ @token.refresh!.to_hash
17
+ end
18
+
19
+ # Retrieve latest activities
20
+ def get_activities()
21
+ Oj.load(@token.get("/v1/my/activities").body)
22
+ end
23
+
24
+ # Filter activities, valid options are: *fromDateUTC*, *page* and *count*
25
+ def search_activities(params={})
26
+ Oj.load(@token.get("/v1/my/activities/search", params).body)
27
+ end
28
+
29
+ # Returns the first 100 smashrun run ids.
30
+ def latest_activities_ids
31
+ Oj.load(@token.get("/v1/my/activities/search/ids").body)
32
+ end
33
+
34
+ # Returns an array of json objects containing the runId, startTime, distance (in kilometers), and duration
35
+ def latest_activities_briefs
36
+ Oj.load(@token.get("/v1/my/activities/search/briefs").body)
37
+ end
38
+
39
+ # To retrieve a Google encoded polyline of a run route to easily draw a route map in Google maps.
40
+ def activity_polyline(activity_id)
41
+ Oj.load(@token.get("/v1/my/activities/#{activity_id}/polyline").body)
42
+ end
43
+
44
+ # To retrieve an SVG polyline of a run route.
45
+ def activity_svg_polyline(activity_id)
46
+ Oj.load(@token.get("/v1/my/activities/#{activity_id}/polyline/svg").body)
47
+ end
48
+
49
+ # To retrieve a GeoJSON representation a run route.
50
+ def activity_geojson(activity_id)
51
+ Oj.load(@token.get("/v1/my/activities/#{activity_id}/polyline/geojson").body)
52
+ end
53
+
54
+ # To retrieve a detail of single activity.
55
+ def activity_detail(activity_id)
56
+ Oj.load(@token.get("/v1/my/activities/#{activity_id}").body)
57
+ end
58
+
59
+ # Retrive activity splits
60
+ def activity_splits(activity_id, unit)
61
+ unless ['km', 'mi'].include?(unit)
62
+ raise ArgumentError.new("Invlaid distance unit for splits. Valid units are km or mi")
63
+ end
64
+
65
+ Oj.load(@token.get("/v1/my/activities/#{activity_id}/splits/#{unit}").body)
66
+ end
67
+
68
+ def profile_info
69
+ Oj.load(@token.get("/v1/my/userinfo").body)
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,9 @@
1
+ module HealthGraph
2
+ module Configuration
3
+ attr_accessor :client_id, :client_secret
4
+
5
+ def configure
6
+ yield self
7
+ end
8
+ end
9
+ end
data/smashrun.gemspec ADDED
@@ -0,0 +1,68 @@
1
+ # Generated by juwelier
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: smashrun 0.1.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "smashrun"
9
+ s.version = "0.1.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Naveed Ahmad"]
14
+ s.date = "2017-10-02"
15
+ s.description = "Ruby gem for Smashrun api"
16
+ s.email = "naveedahmada036@gmail.com"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "lib/smashrun.rb",
30
+ "lib/smashrun/client.rb",
31
+ "lib/smashrun/configuration.rb",
32
+ "smashrun.gemspec",
33
+ "test/helper.rb",
34
+ "test/test_smashrun.rb"
35
+ ]
36
+ s.homepage = "http://github.com/naveed-ahmad/-smashrun"
37
+ s.licenses = ["MIT"]
38
+ s.rubygems_version = "2.4.8"
39
+ s.summary = "Ruby gem for Smashrun api"
40
+
41
+ if s.respond_to? :specification_version then
42
+ s.specification_version = 4
43
+
44
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
+ s.add_runtime_dependency(%q<oauth2>, ["~> 1.4.0"])
46
+ s.add_runtime_dependency(%q<oj>, ["~> 3.3.5"])
47
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
48
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
49
+ s.add_development_dependency(%q<juwelier>, ["~> 2.1.0"])
50
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
51
+ else
52
+ s.add_dependency(%q<oauth2>, ["~> 1.4.0"])
53
+ s.add_dependency(%q<oj>, ["~> 3.3.5"])
54
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
55
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
56
+ s.add_dependency(%q<juwelier>, ["~> 2.1.0"])
57
+ s.add_dependency(%q<simplecov>, [">= 0"])
58
+ end
59
+ else
60
+ s.add_dependency(%q<oauth2>, ["~> 1.4.0"])
61
+ s.add_dependency(%q<oj>, ["~> 3.3.5"])
62
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
63
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
64
+ s.add_dependency(%q<juwelier>, ["~> 2.1.0"])
65
+ s.add_dependency(%q<simplecov>, [">= 0"])
66
+ end
67
+ end
68
+
data/test/helper.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'simplecov'
2
+
3
+ module SimpleCov::Configuration
4
+ def clean_filters
5
+ @filters = []
6
+ end
7
+ end
8
+
9
+ SimpleCov.configure do
10
+ clean_filters
11
+ load_adapter 'test_frameworks'
12
+ end
13
+
14
+ ENV["COVERAGE"] && SimpleCov.start do
15
+ add_filter "/.rvm/"
16
+ end
17
+ require 'rubygems'
18
+ require 'bundler'
19
+ begin
20
+ Bundler.setup(:default, :development)
21
+ rescue Bundler::BundlerError => e
22
+ $stderr.puts e.message
23
+ $stderr.puts "Run `bundle install` to install missing gems"
24
+ exit e.status_code
25
+ end
26
+ require 'test/unit'
27
+ require 'shoulda'
28
+
29
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
30
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
31
+ require 'smashrun'
32
+
33
+ class Test::Unit::TestCase
34
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestSmashrun < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: smashrun-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Naveed Ahmad
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-10-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.4.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.4.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: oj
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 3.3.5
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 3.3.5
41
+ - !ruby/object:Gem::Dependency
42
+ name: rdoc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.12'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.12'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: juwelier
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.1.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.1.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Ruby gem for Smashrun api
98
+ email: naveedahmada036@gmail.com
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files:
102
+ - LICENSE.txt
103
+ - README.rdoc
104
+ files:
105
+ - ".document"
106
+ - Gemfile
107
+ - Gemfile.lock
108
+ - LICENSE.txt
109
+ - README.rdoc
110
+ - Rakefile
111
+ - VERSION
112
+ - lib/smashrun.rb
113
+ - lib/smashrun/client.rb
114
+ - lib/smashrun/configuration.rb
115
+ - smashrun.gemspec
116
+ - test/helper.rb
117
+ - test/test_smashrun.rb
118
+ homepage: http://github.com/naveed-ahmad/smashrun
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.4.8
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: Ruby gem for Smashrun api
142
+ test_files: []