omniauth-napster 0.0.0 → 0.1.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: 6ff9dfeb32f08ffae0527df43cb36aeda85002c2
4
- data.tar.gz: c37b463680191b510f2c2920d0f086ddb04225e7
3
+ metadata.gz: eb41ca84885aa059bf5e4d142ba7562d75d7a31a
4
+ data.tar.gz: e3777f41739b129e8aac19e835e660725aea06d3
5
5
  SHA512:
6
- metadata.gz: 803ff842a2a06e1f10987e47bee024b68edc2d187de0e486c50c127a766a3e0fca00294564ad3afd87e90da45b021fc7a73c5c4f54b7b590850d6d9d955756ca
7
- data.tar.gz: 2246d6ca5cd0aa504e97b4072faf2885625ceef877985be036d18888a04c8d0b76f96a86a09b298f574786fac27616e0bcd3634790d49fd24f606c555da2990f
6
+ metadata.gz: 5a1095637477513335d4e5381b7c22e7e00af3ae90c9e1b080cd0b29cb38ece1b6254003d5c0dfa1059d2e63ad7e8f9ea9ecfc6645cb5c1af5a8217e92482ed0
7
+ data.tar.gz: abfd0e41190f8ab63d41cadc2e81ce2e8c7faec2adc05a2bd2219abf20968adb0bd36ab5b488e02c595c98a901a06d901149284f9885ab7ea5f455e4bb699ea1
data/.gitignore CHANGED
@@ -1,9 +1,4 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
1
+ *.gem
2
+ .bundle
3
+ .config
4
+ Gemfile.lock
data/Gemfile CHANGED
@@ -1,4 +1,2 @@
1
1
  source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in omniauth-napster.gemspec
4
2
  gemspec
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 Jason Kim
3
+ Copyright (c) 2016 Rhapsody International
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
9
  copies of the Software, and to permit persons to whom the Software is
10
10
  furnished to do so, subject to the following conditions:
11
11
 
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
14
 
15
15
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
16
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
17
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
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.
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,41 +1,100 @@
1
- # Omniauth::Napster
1
+ <!--
2
+ [![Gem Version](https://badge.fury.io/rb/omniauth-napster.svg)](https://badge.fury.io/rb/omniauth-napster)
3
+ -->
2
4
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/omniauth/napster`. To experiment with that code, run `bin/console` for an interactive prompt.
5
+ # Napster Music OmniAuth Strategy
4
6
 
5
- TODO: Delete this and the text above, and describe your gem
7
+ This gem provides the [OmniAuth](https://github.com/intridea/omniauth) strategy for the [Napster API](https://developer.napster.com).
6
8
 
7
9
  ## Installation
8
10
 
9
11
  Add this line to your application's Gemfile:
10
12
 
11
- ```ruby
12
- gem 'omniauth-napster'
13
- ```
13
+ ```$ gem 'omniauth-napster'```
14
14
 
15
15
  And then execute:
16
16
 
17
- $ bundle
17
+ ```$ bundle```
18
18
 
19
19
  Or install it yourself as:
20
20
 
21
- $ gem install omniauth-napster
21
+ ```$ gem install omniauth-napster```
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ You'll need to register your app with Napster. Visit https://developer.napster.com/developer/apps/new to get started.
26
26
 
27
- ## Development
27
+ Using this gem is similar to other OmniAuth strategies. Add your app credentials to `config/initializers/omniauth.rb`:
28
28
 
29
- 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.
29
+ ```ruby
30
+ Rails.application.config.middleware.use OmniAuth::Builder do
31
+ provider :napster, ENV['NAPSTER_API_KEY'], ENV['NAPSTER_API_SECRET']
32
+ end
33
+ ```
30
34
 
31
- 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).
35
+ Or with Devise in `config/initializers/devise.rb`:
32
36
 
33
- ## Contributing
37
+ ```ruby
38
+ config.omniauth :napster, ENV['NAPSTER_API_KEY'], ENV['NAPSTER_API_SECRET']
39
+ ```
34
40
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/omniauth-napster.
41
+ ## Auth Hash Schema
36
42
 
43
+ Here's an example auth hash, available in `request.env['omniauth.auth']`:
44
+ ```
45
+ {
46
+ "provider":"napster",
47
+ "uid":"295DC739BEDA4BB8E050960A380358BC",
48
+ "info": {
49
+ "uid":"295DC739BEDA4BB8E050960A380358BC",
50
+ "name":"Testy Testerson",
51
+ "username":"NAPIcat",
52
+ "image":"http://direct.rhapsody.com/imageserver/v2/external/aHR0cHM6Ly9yaGFwc29keS1uYXBpLnMzLmFtYXpvbmF3cy5jb20vbWVtYmVyLzI5NURDNzM5QkVEQTRCQjhFMDUwOTYwQTM4MDM1OEJDL2F2YXRhci9vcmlnaW5hbA%3D%3D/images/108x108.jpg"
53
+ },
54
+ "credentials": {
55
+ "token":"NTQ3NjI5NDktNWIyZC00MDVlLTg2MDMtZDhhMGQ2YTYzMTk3",
56
+ "refresh_token":"0b4bdad8-1c82-44d0-8cdb-dd8d2b6e6331",
57
+ "expires_at":1463103543,
58
+ "expires":true
59
+ },
60
+ "extra": {
61
+ "raw_info": {
62
+ "me": {
63
+ "id": "295DC739BEDA4BB8E050960A380358BC",
64
+ "realName": "Testy Testerson",
65
+ "screenName": "NAPIcat",
66
+ "bio": "The cat is back!",
67
+ "location":"Seattle, WA",
68
+ "visibility": "public",
69
+ "type": "member",
70
+ "href": "http://api.rhapsody.com/members/295DC739BEDA4BB8E050960A380358BC",
71
+ "favoriteAlbumsCount": 0,
72
+ "favoriteArtistsCount": 0,
73
+ "favoriteTracksCount": 0,
74
+ "playlistsTotalCount": 0,
75
+ "playlistsPublishedCount": 0,
76
+ "stationsCount": 0,
77
+ "radioCount": 0,
78
+ "followingCount": 2,
79
+ "followerCount": 10,
80
+ "avatar": "http://direct.rhapsody.com/imageserver/v2/external/aHR0cHM6Ly9yaGFwc29keS1uYXBpLnMzLmFtYXpvbmF3cy5jb20vbWVtYmVyLzI5NURDNzM5QkVEQTRCQjhFMDUwOTYwQTM4MDM1OEJDL2F2YXRhci9vcmlnaW5hbA%3D%3D/images/108x108.jpg",
81
+ "avatarId": "aHR0cHM6Ly9yaGFwc29keS1uYXBpLnMzLmFtYXpvbmF3cy5jb20vbWVtYmVyLzI5NURDNzM5QkVEQTRCQjhFMDUwOTYwQTM4MDM1OEJDL2F2YXRhci9vcmlnaW5hbA%3D%3D",
82
+ "defaultAvatar": "false",
83
+ "avatarVersion": 1465508896140
84
+ }
85
+ }
86
+ }
87
+ }
88
+ ```
37
89
 
38
- ## License
90
+ ## More
39
91
 
40
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
92
+ This gem is brought to you by the NAPI (Napster API) development team. Please [reach out to us](https://groups.google.com/forum/#!forum/rhapsody-api) if you have any questions.
93
+
94
+ ## Contributing
41
95
 
96
+ 1. Fork it
97
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
98
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
99
+ 4. Push to the branch (`git push origin my-new-feature`)
100
+ 5. Create a new Pull Request
data/Rakefile CHANGED
@@ -1,6 +1 @@
1
1
  require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
@@ -0,0 +1,2 @@
1
+ require "omniauth/napster"
2
+ require "omniauth/strategies/napster"
@@ -1,7 +1,5 @@
1
- require "omniauth/napster/version"
2
-
3
- module Omniauth
1
+ module OmniAuth
4
2
  module Napster
5
- # Your code goes here...
3
+ VERSION = "0.1.0"
6
4
  end
7
5
  end
@@ -0,0 +1,36 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Napster < OmniAuth::Strategies::OAuth2
6
+ include OmniAuth::Strategy
7
+ option :name, 'napster'
8
+
9
+ option :client_options, {
10
+ :site => 'https://api.napster.com',
11
+ :token_url => '/oauth/access_token'
12
+ }
13
+
14
+ uid{ raw_info['me']['id'] }
15
+
16
+ info do
17
+ {
18
+ :uid => raw_info['me']['id'],
19
+ :name => raw_info['me']['realName'],
20
+ :username => raw_info['me']['screenName'],
21
+ :image => raw_info['me']['avatar']
22
+ }
23
+ end
24
+
25
+ extra do
26
+ {
27
+ 'raw_info' => raw_info
28
+ }
29
+ end
30
+
31
+ def raw_info
32
+ @raw_info ||= access_token.get('/me').parsed
33
+ end
34
+ end
35
+ end
36
+ end
@@ -1,33 +1,21 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'omniauth/napster/version'
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require 'omniauth/napster'
5
4
 
6
- Gem::Specification.new do |spec|
7
- spec.name = "omniauth-napster"
8
- spec.version = Omniauth::Napster::VERSION
9
- spec.authors = ["Richard Luck"]
10
- spec.email = ["rluck@rhapsody.com"]
11
-
12
- spec.summary = %q{omniauth-napster}
13
- spec.description = %q{omniauth-napster}
14
- spec.homepage = "https://developer.rhapsody.com/"
15
- spec.license = "MIT"
16
-
17
- # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
- # delete this section to allow pushing this gem to any host.
19
- if spec.respond_to?(:metadata)
20
- spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
- else
22
- raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
- end
24
-
25
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
- spec.bindir = "exe"
27
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
- spec.require_paths = ["lib"]
29
-
30
- spec.add_development_dependency "bundler", "~> 1.10"
31
- spec.add_development_dependency "rake", "~> 10.0"
32
- spec.add_development_dependency "rspec"
5
+ Gem::Specification.new do |s|
6
+ s.name = "omniauth-napster"
7
+ s.version = OmniAuth::Napster::VERSION
8
+ s.authors = ["Richard Luck"]
9
+ s.email = ["rluck@rhapsody.com"]
10
+ s.description = %q{This gem provides the OmniAuth strategy for connecting to the Napster API.}
11
+ s.summary = %q{OmniAuth strategy for Napster Music Service}
12
+ s.homepage = "https://github.com/Napster/omniauth-napster.git"
13
+ s.required_ruby_version = '~> 2.0'
14
+ s.license = 'MIT'
15
+ s.files = `git ls-files`.split($/)
16
+ s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
+ s.require_paths = ["lib"]
19
+ s.add_runtime_dependency 'omniauth-oauth2', '~> 1.3'
20
+ s.add_development_dependency 'rspec', '~> 3.0'
33
21
  end
@@ -0,0 +1,6 @@
1
+ require 'spec_helper'
2
+ describe 'OmniAuth::Napster::VERSION' do
3
+ it "should return version number" do
4
+ expect(OmniAuth::Napster::VERSION).to eq('0.1.0')
5
+ end
6
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+ describe 'OmniAuth::Strategies::Napster' do
3
+ subject do
4
+ OmniAuth::Strategies::Napster.new({})
5
+ end
6
+
7
+ context "client options" do
8
+ it 'should have correct name' do
9
+ expect(subject.options.name).to eq("napster")
10
+ end
11
+
12
+ it 'should have correct site' do
13
+ expect(subject.options.client_options.site).to eq('https://api.napster.com')
14
+ end
15
+
16
+ it 'should have correct token url' do
17
+ expect(subject.options.client_options.token_url).to eq('/oauth/access_token')
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,8 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'omniauth-napster'
5
+
6
+ RSpec.configure do |config|
7
+ # some (optional) config here
8
+ end
metadata CHANGED
@@ -1,58 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-napster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Luck
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-09 00:00:00.000000000 Z
11
+ date: 2016-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: omniauth-oauth2
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.10'
20
- type: :development
19
+ version: '1.3'
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.10'
26
+ version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '3.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
41
- - !ruby/object:Gem::Dependency
42
- name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- description: omniauth-napster
40
+ version: '3.0'
41
+ description: This gem provides the OmniAuth strategy for connecting to the Napster
42
+ API.
56
43
  email:
57
44
  - rluck@rhapsody.com
58
45
  executables: []
@@ -61,30 +48,30 @@ extra_rdoc_files: []
61
48
  files:
62
49
  - ".gitignore"
63
50
  - ".rspec"
64
- - ".travis.yml"
65
51
  - Gemfile
66
- - LICENSE.txt
52
+ - LICENSE
67
53
  - README.md
68
54
  - Rakefile
69
- - bin/console
70
- - bin/setup
55
+ - lib/omniauth-napster.rb
71
56
  - lib/omniauth/napster.rb
72
- - lib/omniauth/napster/version.rb
57
+ - lib/omniauth/strategies/napster.rb
73
58
  - omniauth-napster.gemspec
74
- homepage: https://developer.rhapsody.com/
59
+ - spec/omniauth/napster_spec.rb
60
+ - spec/omniauth/strategies/napster_spec.rb
61
+ - spec/spec_helper.rb
62
+ homepage: https://github.com/Napster/omniauth-napster.git
75
63
  licenses:
76
64
  - MIT
77
- metadata:
78
- allowed_push_host: https://rubygems.org
65
+ metadata: {}
79
66
  post_install_message:
80
67
  rdoc_options: []
81
68
  require_paths:
82
69
  - lib
83
70
  required_ruby_version: !ruby/object:Gem::Requirement
84
71
  requirements:
85
- - - ">="
72
+ - - "~>"
86
73
  - !ruby/object:Gem::Version
87
- version: '0'
74
+ version: '2.0'
88
75
  required_rubygems_version: !ruby/object:Gem::Requirement
89
76
  requirements:
90
77
  - - ">="
@@ -92,8 +79,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
79
  version: '0'
93
80
  requirements: []
94
81
  rubyforge_project:
95
- rubygems_version: 2.4.5.1
82
+ rubygems_version: 2.5.1
96
83
  signing_key:
97
84
  specification_version: 4
98
- summary: omniauth-napster
99
- test_files: []
85
+ summary: OmniAuth strategy for Napster Music Service
86
+ test_files:
87
+ - spec/omniauth/napster_spec.rb
88
+ - spec/omniauth/strategies/napster_spec.rb
89
+ - spec/spec_helper.rb
@@ -1,4 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.3
4
- before_install: gem install bundler -v 1.10.6
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "omniauth/napster"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
data/bin/setup DELETED
@@ -1,7 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- bundle install
6
-
7
- # Do any other automated setup that you need to do here
@@ -1,5 +0,0 @@
1
- module Omniauth
2
- module Napster
3
- VERSION = "0.0.0"
4
- end
5
- end