omniauth-lastfm 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +2 -0
- data/README.md +89 -0
- data/Rakefile +6 -1
- data/lib/omniauth-lastfm/version.rb +2 -2
- data/lib/omniauth/strategies/lastfm.rb +1 -1
- data/omniauth-lastfm.gemspec +2 -2
- data/spec/omniauth/strategies/lastfm_spec.rb +26 -0
- data/spec/spec_helper.rb +7 -0
- metadata +17 -11
data/.rspec
ADDED
data/README.md
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
OmniAuth Last.fm
|
2
|
+
================
|
3
|
+
|
4
|
+
Last.fm strategy for OmniAuth 1.0.
|
5
|
+
|
6
|
+
Installing
|
7
|
+
----------
|
8
|
+
Add to your Gemfile:
|
9
|
+
|
10
|
+
gem 'omniauth'
|
11
|
+
gem 'omniauth-lastfm'
|
12
|
+
|
13
|
+
Then `bundle install`.
|
14
|
+
|
15
|
+
Usage
|
16
|
+
-----
|
17
|
+
You'll need an API account with Last.fm, you can get one here - http://www.last.fm/api.
|
18
|
+
|
19
|
+
Usage of the gem is very similar to other OmniAuth 1.0 strategies. You'll need to add your API keys to `config/initializers/omniauth.rb`:
|
20
|
+
|
21
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
22
|
+
provider :lastfm, "consumer_key", "consumer_secret"
|
23
|
+
end
|
24
|
+
|
25
|
+
Now simply follow the README at: https://github.com/intridea/omniauth.
|
26
|
+
|
27
|
+
Auth Hash Schema
|
28
|
+
----------------
|
29
|
+
Here's an example auth hash, available in `request.env['omniauth.auth']`:
|
30
|
+
|
31
|
+
{
|
32
|
+
"provider": "lastfm",
|
33
|
+
"uid": "ripuk",
|
34
|
+
"info": {
|
35
|
+
"nickname": "ripuk",
|
36
|
+
"name": "David Stephens",
|
37
|
+
"url": "http://www.last.fm/user/ripuk",
|
38
|
+
"image": "http://userserve-ak.last.fm/serve/252/46787679.jpg",
|
39
|
+
"country": "UK",
|
40
|
+
"age": "31",
|
41
|
+
"gender": "m"
|
42
|
+
},
|
43
|
+
"credentials": {
|
44
|
+
"token": "abcdefghijklmnop",
|
45
|
+
"name": "ripuk"
|
46
|
+
},
|
47
|
+
"extra": {
|
48
|
+
"raw_info": {
|
49
|
+
"name": "ripuk",
|
50
|
+
"realname": "David Stephens",
|
51
|
+
"image": [
|
52
|
+
{
|
53
|
+
"#text": "http://userserve-ak.last.fm/serve/34/46787679.jpg",
|
54
|
+
"size": "small"
|
55
|
+
},
|
56
|
+
{
|
57
|
+
"#text": "http://userserve-ak.last.fm/serve/64/46787679.jpg",
|
58
|
+
"size": "medium"
|
59
|
+
},
|
60
|
+
{
|
61
|
+
"#text": "http://userserve-ak.last.fm/serve/126/46787679.jpg",
|
62
|
+
"size": "large"
|
63
|
+
},
|
64
|
+
{
|
65
|
+
"#text": "http://userserve-ak.last.fm/serve/252/46787679.jpg",
|
66
|
+
"size": "extralarge"
|
67
|
+
}
|
68
|
+
],
|
69
|
+
"url": "http://www.last.fm/user/ripuk",
|
70
|
+
"id": "25400308",
|
71
|
+
"country": "UK",
|
72
|
+
"age": "31",
|
73
|
+
"gender": "m",
|
74
|
+
"subscriber": "0",
|
75
|
+
"playcount": "11530",
|
76
|
+
"playlists": "0",
|
77
|
+
"bootstrap": "0",
|
78
|
+
"registered": {
|
79
|
+
"#text": "2009-12-30 00:53",
|
80
|
+
"unixtime": "1262134389"
|
81
|
+
},
|
82
|
+
"type": "user"
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
What Next?
|
88
|
+
----------
|
89
|
+
The [Rockstar Gem](https://github.com/putpat/rockstar) is a great way to make use of the auth token retrieved with this gem.
|
data/Rakefile
CHANGED
@@ -67,7 +67,7 @@ module OmniAuth
|
|
67
67
|
:image => @json['user']['image'].instance_of?(Array) ? @json['user']['image'].last['#text'] : @json['user']['image'],
|
68
68
|
:country => @json['user']['country'],
|
69
69
|
:age => @json['user']['age'],
|
70
|
-
:gender => @json['user']['
|
70
|
+
:gender => @json['user']['gender'],
|
71
71
|
}
|
72
72
|
end
|
73
73
|
|
data/omniauth-lastfm.gemspec
CHANGED
@@ -4,7 +4,7 @@ require "omniauth-lastfm/version"
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "omniauth-lastfm"
|
7
|
-
s.version =
|
7
|
+
s.version = OmniAuth::Lastfm::VERSION
|
8
8
|
s.authors = ["Claudio Poli"]
|
9
9
|
s.email = ["claudio@audiobox.fm"]
|
10
10
|
s.homepage = "http://github.com/masterkain/omniauth-lastfm"
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
s.add_development_dependency "rspec", "~> 2.
|
21
|
+
s.add_development_dependency "rspec", "~> 2.10"
|
22
22
|
s.add_development_dependency "rack-test"
|
23
23
|
s.add_development_dependency "simplecov"
|
24
24
|
s.add_development_dependency "webmock"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::Lastfm do
|
4
|
+
subject do
|
5
|
+
OmniAuth::Strategies::Lastfm.new({})
|
6
|
+
end
|
7
|
+
|
8
|
+
context 'client options' do
|
9
|
+
it 'should have the correct name' do
|
10
|
+
subject.options.name.should eq('lastfm')
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should have correct site' do
|
14
|
+
subject.options.client_options.site.should eq('http://www.last.fm')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should have correct api url' do
|
18
|
+
subject.options.client_options.api_url.should eq('http://ws.audioscrobbler.com/2.0/')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have correct authorize path' do
|
22
|
+
subject.options.client_options.authorize_path.should eq('/api/auth')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-lastfm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.3
|
5
4
|
prerelease:
|
5
|
+
version: 0.0.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Claudio Poli
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
+
type: :development
|
16
17
|
requirement: !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
19
|
requirements:
|
19
20
|
- - ~>
|
20
21
|
- !ruby/object:Gem::Version
|
21
|
-
version: '2.
|
22
|
-
type: :development
|
22
|
+
version: '2.10'
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '2.
|
29
|
+
version: '2.10'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rack-test
|
32
|
+
type: :development
|
32
33
|
requirement: !ruby/object:Gem::Requirement
|
33
34
|
none: false
|
34
35
|
requirements:
|
35
36
|
- - ! '>='
|
36
37
|
- !ruby/object:Gem::Version
|
37
38
|
version: '0'
|
38
|
-
type: :development
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
@@ -45,13 +45,13 @@ dependencies:
|
|
45
45
|
version: '0'
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: simplecov
|
48
|
+
type: :development
|
48
49
|
requirement: !ruby/object:Gem::Requirement
|
49
50
|
none: false
|
50
51
|
requirements:
|
51
52
|
- - ! '>='
|
52
53
|
- !ruby/object:Gem::Version
|
53
54
|
version: '0'
|
54
|
-
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
@@ -61,13 +61,13 @@ dependencies:
|
|
61
61
|
version: '0'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: webmock
|
64
|
+
type: :development
|
64
65
|
requirement: !ruby/object:Gem::Requirement
|
65
66
|
none: false
|
66
67
|
requirements:
|
67
68
|
- - ! '>='
|
68
69
|
- !ruby/object:Gem::Version
|
69
70
|
version: '0'
|
70
|
-
type: :development
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
@@ -77,13 +77,13 @@ dependencies:
|
|
77
77
|
version: '0'
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: omniauth-oauth
|
80
|
+
type: :runtime
|
80
81
|
requirement: !ruby/object:Gem::Requirement
|
81
82
|
none: false
|
82
83
|
requirements:
|
83
84
|
- - ~>
|
84
85
|
- !ruby/object:Gem::Version
|
85
86
|
version: '1.0'
|
86
|
-
type: :runtime
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
89
|
none: false
|
@@ -93,13 +93,13 @@ dependencies:
|
|
93
93
|
version: '1.0'
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: rest-client
|
96
|
+
type: :runtime
|
96
97
|
requirement: !ruby/object:Gem::Requirement
|
97
98
|
none: false
|
98
99
|
requirements:
|
99
100
|
- - ~>
|
100
101
|
- !ruby/object:Gem::Version
|
101
102
|
version: 1.6.6
|
102
|
-
type: :runtime
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
@@ -115,12 +115,16 @@ extensions: []
|
|
115
115
|
extra_rdoc_files: []
|
116
116
|
files:
|
117
117
|
- .gitignore
|
118
|
+
- .rspec
|
118
119
|
- Gemfile
|
120
|
+
- README.md
|
119
121
|
- Rakefile
|
120
122
|
- lib/omniauth-lastfm.rb
|
121
123
|
- lib/omniauth-lastfm/version.rb
|
122
124
|
- lib/omniauth/strategies/lastfm.rb
|
123
125
|
- omniauth-lastfm.gemspec
|
126
|
+
- spec/omniauth/strategies/lastfm_spec.rb
|
127
|
+
- spec/spec_helper.rb
|
124
128
|
homepage: http://github.com/masterkain/omniauth-lastfm
|
125
129
|
licenses: []
|
126
130
|
post_install_message:
|
@@ -145,4 +149,6 @@ rubygems_version: 1.8.24
|
|
145
149
|
signing_key:
|
146
150
|
specification_version: 3
|
147
151
|
summary: OmniAuth strategy for Last.fm
|
148
|
-
test_files:
|
152
|
+
test_files:
|
153
|
+
- spec/omniauth/strategies/lastfm_spec.rb
|
154
|
+
- spec/spec_helper.rb
|