omniauth-mapmyfitness 0.0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .DS_Store
data/Gemfile CHANGED
@@ -9,4 +9,6 @@ group :development, :test do
9
9
  gem 'guard-bundler'
10
10
  gem 'growl'
11
11
  gem 'rb-fsevent'
12
+ gem 'nokogiri'
13
+ gem 'multi_xml'
12
14
  end
data/README.md CHANGED
@@ -1,24 +1,43 @@
1
1
  # Omniauth::Mapmyfitness
2
2
 
3
- TODO: Write a gem description
3
+ OmniAuth Strategy for [Map My Fitness API](http://api.mapmyfitness.com/3.1/)
4
4
 
5
5
  ## Installation
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- gem 'omniauth-mapmyfitness'
10
-
9
+ ```ruby
10
+ gem 'omniauth-mapmyfitness'
11
+ ```
11
12
  And then execute:
12
13
 
13
- $ bundle
14
-
14
+ ```ruby
15
+ $ bundle
16
+ ```
15
17
  Or install it yourself as:
16
18
 
17
- $ gem install omniauth-mapmyfitness
19
+ ```ruby
20
+ $ gem install omniauth-mapmyfitness
21
+ ```
18
22
 
19
23
  ## Usage
20
24
 
21
- TODO: Write usage instructions here
25
+ To integrate the strategy into your middleware:
26
+
27
+ ```ruby
28
+ use OmniAuth::Builder do
29
+ provider :mapmyfitness, ENV['consumer_key'], ENV['secret_key']
30
+ end
31
+ ```
32
+
33
+ In Rails, you'll want to add a middleware stack or define it inside an initializer file `config/initializers/omniauth.rb`
34
+
35
+ ```ruby
36
+ Rails.application.config.middleware.use OmniAuth::Builder do
37
+ provider :mapmyfitness, ENV['consumer_key'], ENV['secret_key']
38
+ end
39
+ ```
40
+
22
41
 
23
42
  ## Contributing
24
43
 
@@ -1,4 +1,5 @@
1
1
  require "omniauth-oauth"
2
+ require "multi_xml"
2
3
 
3
4
  module OmniAuth
4
5
  module Strategies
@@ -10,6 +11,24 @@ module OmniAuth
10
11
  :site => "http://api.mapmyfitness.com/3.1"
11
12
  }
12
13
 
14
+ uid { raw_info['result']['output']['user']['user_id'] }
15
+
16
+ info do
17
+ {
18
+ :email => raw_info['result']['output']['user']['email'],
19
+ :first_name => raw_info['result']['output']['user']['first_name'],
20
+ :last_name => raw_info['result']['output']['user']['last_name']
21
+ }
22
+ end
23
+
24
+ extra do
25
+ { 'raw_info' => raw_info }
26
+ end
27
+
28
+ def raw_info
29
+ @raw_info ||= MultiXml.parse(access_token.get("/users/get_user?o=xml").body)
30
+ end
31
+
13
32
  end
14
33
 
15
34
  end
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Mapmyfitness
3
- VERSION = "0.0.1"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -10,16 +10,15 @@ Gem::Specification.new do |gem|
10
10
  gem.email = ["baldrailers@gmail.com"]
11
11
  gem.description = %q{OmniOauth strategy for mapmyfitness}
12
12
  gem.summary = gem.description
13
- gem.homepage = "https://github.com/baldrailers"
13
+ gem.homepage = "https://github.com/baldrailers/omniauth-mapmyfitness"
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
- gem.add_runtime_dependency 'omniauth', '~> 1.0'
21
20
  gem.add_runtime_dependency 'omniauth-oauth'
22
- gem.add_runtime_dependency 'oauth'
21
+ gem.add_runtime_dependency 'multi_xml'
23
22
 
24
23
  gem.add_development_dependency 'rspec'
25
24
  gem.add_development_dependency 'webmock'
@@ -2,6 +2,26 @@ require 'spec_helper'
2
2
 
3
3
  describe "OmniAuth::Strategies::Mapmyfitness" do
4
4
 
5
- it { should be_a_kind_of OmniAuth::Strategies::OAuth }
5
+ subject do
6
+ OmniAuth::Strategies::Mapmyfitness.new(nil, @options || {})
7
+ end
8
+
9
+ context 'client options' do
10
+ it 'has correct Mapmyfitness site' do
11
+ subject.options.client_options.site.should eq('http://api.mapmyfitness.com/3.1')
12
+ end
13
+ end
14
+
15
+ # uid { raw_info['result']['output']['user']['user_id'] }
16
+ context '#uid' do
17
+ before :each do
18
+ subject.stub(:raw_info) { { 'user_id' => '123'} }
19
+ end
20
+
21
+ it 'returns the user_id from raw_info' do
22
+ subject.uid.should eq('123')
23
+ end
24
+
25
+ end
6
26
 
7
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-mapmyfitness
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,22 +11,6 @@ bindir: bin
11
11
  cert_chain: []
12
12
  date: 2012-10-12 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: omniauth
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: '1.0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- version: '1.0'
30
14
  - !ruby/object:Gem::Dependency
31
15
  name: omniauth-oauth
32
16
  requirement: !ruby/object:Gem::Requirement
@@ -44,7 +28,7 @@ dependencies:
44
28
  - !ruby/object:Gem::Version
45
29
  version: '0'
46
30
  - !ruby/object:Gem::Dependency
47
- name: oauth
31
+ name: multi_xml
48
32
  requirement: !ruby/object:Gem::Requirement
49
33
  none: false
50
34
  requirements:
@@ -159,7 +143,7 @@ files:
159
143
  - omniauth-mapmyfitness.gemspec
160
144
  - spec/omniauth/strategies/mapmyfitness_spec.rb
161
145
  - spec/spec_helper.rb
162
- homepage: https://github.com/baldrailers
146
+ homepage: https://github.com/baldrailers/omniauth-mapmyfitness
163
147
  licenses: []
164
148
  post_install_message:
165
149
  rdoc_options: []
@@ -173,7 +157,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
173
157
  version: '0'
174
158
  segments:
175
159
  - 0
176
- hash: 1663477099253266433
160
+ hash: -577243975416488922
177
161
  required_rubygems_version: !ruby/object:Gem::Requirement
178
162
  none: false
179
163
  requirements:
@@ -182,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
166
  version: '0'
183
167
  segments:
184
168
  - 0
185
- hash: 1663477099253266433
169
+ hash: -577243975416488922
186
170
  requirements: []
187
171
  rubyforge_project:
188
172
  rubygems_version: 1.8.24