omniauth-mapmytri 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/.rspec +1 -0
- data/Gemfile +14 -0
- data/Guardfile +11 -0
- data/LICENSE.txt +22 -0
- data/README.md +48 -0
- data/Rakefile +9 -0
- data/lib/omniauth-mapmytri.rb +2 -0
- data/lib/omniauth-mapmytri/version.rb +5 -0
- data/lib/omniauth/strategies/mapmytri.rb +37 -0
- data/omniauth-mapmytri.gemspec +28 -0
- data/spec/omniauth/strategies/mapmytri_spec.rb +27 -0
- data/spec/spec_helper.rb +16 -0
- metadata +178 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in omniauth-mapmytri.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :development, :test do
|
7
|
+
gem 'guard'
|
8
|
+
gem 'guard-rspec'
|
9
|
+
gem 'guard-bundler'
|
10
|
+
gem 'growl'
|
11
|
+
gem 'rb-fsevent'
|
12
|
+
gem 'nokogiri'
|
13
|
+
gem 'multi_xml'
|
14
|
+
end
|
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Julius Francisco
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# Omniauth::MapMyTri
|
2
|
+
|
3
|
+
OmniAuth Strategy for [Map My Fitness API](http://api.mapmyfitness.com/3.1/)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'omniauth-mapmytri'
|
11
|
+
```
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
$ bundle
|
16
|
+
```
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
$ gem install omniauth-mapmytri
|
21
|
+
```
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
To integrate the strategy into your middleware:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
use OmniAuth::Builder do
|
29
|
+
provider :mapmytri, 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 :mapmytri, ENV['consumer_key'], ENV['secret_key']
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
|
42
|
+
## Contributing
|
43
|
+
|
44
|
+
1. Fork it
|
45
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
46
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
47
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
48
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require "omniauth-oauth"
|
2
|
+
require "multi_xml"
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
|
7
|
+
class MapMyTri < OmniAuth::Strategies::OAuth
|
8
|
+
option :name, "mapmytri"
|
9
|
+
|
10
|
+
option :client_options, {
|
11
|
+
:site => "http://api.mapmyfitness.com/3.1"
|
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
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
OmniAuth.config.add_camelization 'mapmytri', 'MapMyTri'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'omniauth-mapmytri/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "omniauth-mapmytri"
|
8
|
+
gem.version = Omniauth::MapMyTri::VERSION
|
9
|
+
gem.authors = ["Julius Francisco"]
|
10
|
+
gem.email = ["baldrailers@gmail.com"]
|
11
|
+
gem.description = %q{OmniOauth strategy for MapMyTri}
|
12
|
+
gem.summary = gem.description
|
13
|
+
gem.homepage = "https://github.com/baldrailers/omniauth-mapmytri"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_runtime_dependency 'omniauth-oauth'
|
21
|
+
gem.add_runtime_dependency 'multi_xml'
|
22
|
+
|
23
|
+
gem.add_development_dependency 'rspec'
|
24
|
+
gem.add_development_dependency 'webmock'
|
25
|
+
gem.add_development_dependency 'simplecov'
|
26
|
+
gem.add_development_dependency 'rack-test'
|
27
|
+
gem.add_development_dependency 'rake'
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "OmniAuth::Strategies::MapMyTri" do
|
4
|
+
|
5
|
+
subject do
|
6
|
+
OmniAuth::Strategies::MapMyTri.new(nil, @options || {})
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'client options' do
|
10
|
+
it 'has correct MapMyTri 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
|
26
|
+
|
27
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
|
4
|
+
require 'simplecov'
|
5
|
+
SimpleCov.start
|
6
|
+
require 'rspec'
|
7
|
+
require 'rack/test'
|
8
|
+
require 'webmock/rspec'
|
9
|
+
require 'omniauth-oauth'
|
10
|
+
require 'omniauth-mapmytri'
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.include WebMock::API
|
14
|
+
config.include Rack::Test::Methods
|
15
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-mapmytri
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Julius Francisco
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-13 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth-oauth
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '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: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: multi_xml
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: webmock
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: simplecov
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rack-test
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: rake
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
description: OmniOauth strategy for MapMyTri
|
127
|
+
email:
|
128
|
+
- baldrailers@gmail.com
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- .gitignore
|
134
|
+
- .rspec
|
135
|
+
- Gemfile
|
136
|
+
- Guardfile
|
137
|
+
- LICENSE.txt
|
138
|
+
- README.md
|
139
|
+
- Rakefile
|
140
|
+
- lib/omniauth-mapmytri.rb
|
141
|
+
- lib/omniauth-mapmytri/version.rb
|
142
|
+
- lib/omniauth/strategies/mapmytri.rb
|
143
|
+
- omniauth-mapmytri.gemspec
|
144
|
+
- spec/omniauth/strategies/mapmytri_spec.rb
|
145
|
+
- spec/spec_helper.rb
|
146
|
+
homepage: https://github.com/baldrailers/omniauth-mapmytri
|
147
|
+
licenses: []
|
148
|
+
post_install_message:
|
149
|
+
rdoc_options: []
|
150
|
+
require_paths:
|
151
|
+
- lib
|
152
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
segments:
|
159
|
+
- 0
|
160
|
+
hash: -1391063022199448057
|
161
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
+
none: false
|
163
|
+
requirements:
|
164
|
+
- - ! '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
segments:
|
168
|
+
- 0
|
169
|
+
hash: -1391063022199448057
|
170
|
+
requirements: []
|
171
|
+
rubyforge_project:
|
172
|
+
rubygems_version: 1.8.24
|
173
|
+
signing_key:
|
174
|
+
specification_version: 3
|
175
|
+
summary: OmniOauth strategy for MapMyTri
|
176
|
+
test_files:
|
177
|
+
- spec/omniauth/strategies/mapmytri_spec.rb
|
178
|
+
- spec/spec_helper.rb
|