omniauth-mapmyfitness-oauth2 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1adbe1b10480660f1d3479ef8cbab69db46ac8f8
4
- data.tar.gz: f597ab491059907662168fdbe0ea71d27044c323
3
+ metadata.gz: 8de76e8c2a4bb7fe06395671b98ee6017053e746
4
+ data.tar.gz: b02172c1983e95418e3cbee0608c3f663837afbd
5
5
  SHA512:
6
- metadata.gz: f43a10c9e81922e3da89ddf95c098dceb7f42c0229ebedff1f830c6a511e92f3d0c78e0e7412f05369b84966d4d0d90138fe53a1a500156f99a8bbe9cc57bfff
7
- data.tar.gz: 2172a69c60a3078b6f2120943cec59fb970441309f089b65d1f9f54969caa9351ece77adac0e20507f1af36ae632c89e5f67fb907d57ce1a0d03b8d5f62922f3
6
+ metadata.gz: ad10cacc9128012b5505df663d395dd9f679336ecd07d59c7abf019c738ae6c41f7a40039e430bd532247ed74eafb083287e23b52afc8aae787360f4fc4f155a
7
+ data.tar.gz: 80b016b9cd1ae2573782704c7eaaec546d39429f6a4a16fe34d51ba1b6d25f19d56d6e51b591187d0e3a820911422e85b13e51bf696ff7c4728d9e8a91f5ae32
@@ -0,0 +1,30 @@
1
+ module OmniAuth
2
+ module MapMyFitness
3
+ class User
4
+ def self.data_attributes
5
+ ["username", "first_name", "last_name", "display_name", "last_initial",
6
+ "weight", "communication", "display_measurement_system", "time_zone",
7
+ "birthdate", "height", "email", "sharing", "last_login", "location",
8
+ "gender", "_links", "id", "date_joined"]
9
+ end
10
+
11
+ attr_reader :data, :token_expires_at, :token_refresh, :token
12
+ attr_reader *data_attributes
13
+
14
+ def initialize(auth_info)
15
+ @data = auth_info
16
+ parse_attributes
17
+ end
18
+
19
+ def parse_attributes
20
+ User.data_attributes.each do |attribute|
21
+ instance_variable_set("@#{attribute}", data["info"][attribute])
22
+ end
23
+ @token_expires = data["credentials"]["expires"]
24
+ @token_expires_at = data["credentials"]["expires_at"]
25
+ @token_refresh = data["credentials"]["refresh_token"]
26
+ @token = data["credentials"]["token"]
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module MapMyFitness
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  require 'omniauth-oauth2'
2
- require 'pry'
2
+ require 'omniauth-mapmyfitness-oauth2/user'
3
3
 
4
4
  module OmniAuth
5
5
  module Strategies
@@ -15,35 +15,14 @@ module OmniAuth
15
15
  }
16
16
  }
17
17
 
18
- option :token_options, {
19
- :grant_type => 'authorization_code',
20
- }
18
+ option :token_options, { :grant_type => 'authorization_code' }
21
19
 
22
- uid {
23
- raw_info['user_id']
24
- }
20
+ uid{ raw_info['user_id'] }
25
21
 
26
- info do
27
- {
28
- :name => "#{raw_info['first_name']} #{raw_info['last_name']}",
29
- :email => raw_info['email'],
30
- :nickname => raw_info['username'],
31
- :first_name => raw_info['first_name'],
32
- :last_name => raw_info['last_name'],
33
- :location => [raw_info['start_city'], raw_info['start_state'], raw_info['start_country']].join(', '),
34
- #:image => "http://api.mapmyfitness.com/3.1/users/get_avatar?uid=#{raw_info['user_id']}",
35
- :urls => {:mapmyfitness => "http://www.mapmyfitness.com/profile/#{raw_info['username']}"}
36
- }
37
- end
38
-
39
- extra do
40
- {
41
- 'raw_info' => raw_info
42
- }
43
- end
22
+ info{ raw_info }
44
23
 
45
24
  def raw_info
46
- @raw_info = JSON.parse(access_token.get("/v7.0/user/self").body)
25
+ @raw_info ||= JSON.parse(access_token.get("/v7.0/user/self").body)
47
26
  end
48
27
  end
49
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-mapmyfitness-oauth2
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
  - Jeff Casimir
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-10 00:00:00.000000000 Z
11
+ date: 2014-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -96,6 +96,7 @@ files:
96
96
  - Rakefile
97
97
  - VERSION
98
98
  - lib/omniauth-mapmyfitness-oauth2.rb
99
+ - lib/omniauth-mapmyfitness-oauth2/user.rb
99
100
  - lib/omniauth-mapmyfitness-oauth2/version.rb
100
101
  - lib/omniauth/strategies/mapmyfitness.rb
101
102
  - omniauth-mapmyfitness-oauth2.gemspec