omniauth-mapmyhike 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .DS_Store
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-mapmyhike.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
@@ -0,0 +1,11 @@
1
+ guard 'rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
6
+
7
+
8
+ guard 'bundler' do
9
+ watch('Gemfile')
10
+ watch(/^.+\.gemspec/)
11
+ end
@@ -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.
@@ -0,0 +1,48 @@
1
+ # Omniauth::MapMyHike
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-mapmyhike'
11
+ ```
12
+ And then execute:
13
+
14
+ ```ruby
15
+ $ bundle
16
+ ```
17
+ Or install it yourself as:
18
+
19
+ ```ruby
20
+ $ gem install omniauth-mapmyhike
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ To integrate the strategy into your middleware:
26
+
27
+ ```ruby
28
+ use OmniAuth::Builder do
29
+ provider :mapmyhike, 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 :mapmyhike, 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
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
+
5
+ desc 'Default: run specs.'
6
+ task :default => :spec
7
+
8
+ desc "Run specs"
9
+ RSpec::Core::RakeTask.new
@@ -0,0 +1,2 @@
1
+ require "omniauth-mapmyhike/version"
2
+ require "omniauth/strategies/mapmyhike"
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module MapMyHike
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
@@ -0,0 +1,37 @@
1
+ require "omniauth-oauth"
2
+ require "multi_xml"
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+
7
+ class MapMyHike < OmniAuth::Strategies::OAuth
8
+ option :name, "mapmyhike"
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 'mapmyhike', 'MapMyHike'
@@ -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-mapmyhike/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "omniauth-mapmyhike"
8
+ gem.version = Omniauth::MapMyHike::VERSION
9
+ gem.authors = ["Julius Francisco"]
10
+ gem.email = ["baldrailers@gmail.com"]
11
+ gem.description = %q{OmniOauth strategy for MapMyHike}
12
+ gem.summary = gem.description
13
+ gem.homepage = "https://github.com/baldrailers/omniauth-mapmyhike"
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::MapMyHike" do
4
+
5
+ subject do
6
+ OmniAuth::Strategies::MapMyHike.new(nil, @options || {})
7
+ end
8
+
9
+ context 'client options' do
10
+ it 'has correct MapMyHike 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
@@ -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-mapmyhike'
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-mapmyhike
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 MapMyHike
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-mapmyhike.rb
141
+ - lib/omniauth-mapmyhike/version.rb
142
+ - lib/omniauth/strategies/mapmyhike.rb
143
+ - omniauth-mapmyhike.gemspec
144
+ - spec/omniauth/strategies/mapmyhike_spec.rb
145
+ - spec/spec_helper.rb
146
+ homepage: https://github.com/baldrailers/omniauth-mapmyhike
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: -2708088215902717748
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: -2708088215902717748
170
+ requirements: []
171
+ rubyforge_project:
172
+ rubygems_version: 1.8.24
173
+ signing_key:
174
+ specification_version: 3
175
+ summary: OmniOauth strategy for MapMyHike
176
+ test_files:
177
+ - spec/omniauth/strategies/mapmyhike_spec.rb
178
+ - spec/spec_helper.rb