omniauth-hattrick 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fcf11e48c59fd1ccd89279ee0c1fe34b9fe641d3
4
+ data.tar.gz: 37c7689bcb6379543e3b4d5fe3d4d1f5ea6f13a8
5
+ SHA512:
6
+ metadata.gz: f2959ddbb190f0b8feb5dbd8696e38aaca8d6c0a89e4c7e6ae77447a13465b0e6a7441444cbd48d1e04caa642f47df15ffd43f8131d492fac49943e8f5401e13
7
+ data.tar.gz: 48881b1e97018f24fa8fff6db91533b647242240f64067a42de61b4478fb5dfec39f5abf969e24ec81e993e4dd59b3bcc241d8037b4aa2becb3e85b4355e4618
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /bin/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-hattrick.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 James Doyley
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # Omniauth::Hattrick
2
+
3
+ [Hattrick](https://www.hattrick.org) CHPP OmniAuth Strategy
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'omniauth-hattrick'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install omniauth-hattrick
20
+
21
+ ## Usage
22
+
23
+ Tell OmniAuth about this provider.
24
+
25
+ Rails.application.config.middleware.use OmniAuth::Builder do
26
+ provider :hattrick, ENV['HATTRICK_KEY'], ENV['HATTRICK_SECRET']
27
+ end
28
+
29
+ `"HATTRICK_KEY"` and `"HATTRICK_SECRET"` should be your CHPP product's consumer key and consumer secret
30
+
31
+ Next configure your routes
32
+
33
+ get 'auth/:provider/callback', to: 'sessions#create'·
34
+
35
+ ## Hash returned
36
+
37
+ At the moment all that is returned is the token, token secret, user id and username as that is all I think we need.
38
+
39
+ ## Development
40
+
41
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
42
+
43
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
44
+
45
+ ## Contributing
46
+
47
+ Bug reports and pull requests are welcome on GitHub at https://github.com/j-dexx/omniauth-hattrick.
48
+
49
+
50
+ ## License
51
+
52
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
53
+
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
8
+ task :console do
9
+ exec "irb -r omniauth-hattrick -I ./lib"
10
+ end
@@ -0,0 +1,3 @@
1
+ require "omniauth-hattrick/version"
2
+ require "omniauth-hattrick/xml_parser"
3
+ require 'omniauth/strategies/hattrick'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Hattrick
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,35 @@
1
+ require 'nokogiri'
2
+
3
+ module OmniAuth
4
+ module Hattrick
5
+ class XmlParser
6
+
7
+ attr_reader :xml
8
+
9
+ def initialize(xml)
10
+ @doc = Nokogiri::XML(xml)
11
+ @manager_details = {}
12
+ end
13
+
14
+ def parse
15
+ add_user_id
16
+ add_username
17
+ manager_details
18
+ end
19
+
20
+ private
21
+
22
+ attr_accessor :manager_details
23
+ attr_reader :doc
24
+
25
+ def add_user_id
26
+ manager_details[:user_id] = doc.xpath('//UserId').text
27
+ end
28
+
29
+ def add_username
30
+ manager_details[:username] = doc.xpath('//Loginname').text
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,26 @@
1
+ require 'omniauth-oauth'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Hattrick < OmniAuth::Strategies::OAuth
6
+ option :name, 'hattrick'
7
+
8
+ option :client_options, {
9
+ site: 'https://chpp.hattrick.org',
10
+ request_token_path: '/oauth/request_token.ashx',
11
+ authorize_path: '/oauth/authorize.aspx',
12
+ access_token_path: '/oauth/access_token.ashx',
13
+ }
14
+
15
+ uid { raw_info[:user_id] }
16
+
17
+ info do
18
+ raw_info
19
+ end
20
+
21
+ def raw_info
22
+ @raw_info ||= OmniAuth::Hattrick::XmlParser.new(access_token.get('http://chpp.hattrick.org/chppxml.ashx?file=managercompendium&version=1.0').body).parse
23
+ end
24
+ end
25
+ end
26
+ end
data/lib/test.rb ADDED
File without changes
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth-hattrick/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-hattrick"
8
+ spec.version = OmniAuth::Hattrick::VERSION
9
+ spec.authors = ["James Doyley"]
10
+ spec.email = ["jdoyley@gmail.com"]
11
+
12
+ spec.summary = %q{ An omniauth strategy for hattrick.}
13
+ spec.description = %q{ An omniauth strategy for CHPP products on hattrick.org.}
14
+ spec.homepage = "https://github.com/j-dexx/omniauth-hattrick"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency 'omniauth-oauth', '~> 1.1'
23
+ spec.add_dependency 'nokogiri', '~> 1.6', '>= 1.6.7.1'
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.10"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec"
28
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-hattrick
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Doyley
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-12-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth-oauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 1.6.7.1
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '1.6'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.6.7.1
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.10'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.10'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '10.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '10.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ description: " An omniauth strategy for CHPP products on hattrick.org."
90
+ email:
91
+ - jdoyley@gmail.com
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - ".gitignore"
97
+ - ".rspec"
98
+ - ".travis.yml"
99
+ - Gemfile
100
+ - LICENSE.txt
101
+ - README.md
102
+ - Rakefile
103
+ - bin/console
104
+ - bin/setup
105
+ - lib/omniauth-hattrick.rb
106
+ - lib/omniauth-hattrick/version.rb
107
+ - lib/omniauth-hattrick/xml_parser.rb
108
+ - lib/omniauth/strategies/hattrick.rb
109
+ - lib/test.rb
110
+ - omniauth-hattrick.gemspec
111
+ homepage: https://github.com/j-dexx/omniauth-hattrick
112
+ licenses:
113
+ - MIT
114
+ metadata: {}
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 2.4.5.1
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: An omniauth strategy for hattrick.
135
+ test_files: []