omniauth-yandex 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,12 @@
1
- # OmniAuth Yandex.ru
1
+ # Yandex OAuth strategy for OmniAuth
2
2
 
3
- This gem contains the unofficial Yandex.ru OAuth2 strategy for [OmniAuth](http://github.com/intridea/omniauth).
3
+ This gem contains the unofficial Yandex OAuth2 strategy for [OmniAuth](http://github.com/intridea/omniauth).
4
+
5
+ ## Installation
6
+
7
+ gem "omniauth-yandex"
8
+
9
+ Also, you have to obtain API key for your app at Yandex [OAuth app registration page](https://oauth.yandex.ru/client/new)
4
10
 
5
11
  ## Basic Usage
6
12
 
@@ -15,4 +21,4 @@ This gem contains the unofficial Yandex.ru OAuth2 strategy for [OmniAuth](http:/
15
21
 
16
22
  ## License
17
23
 
18
- Copyright (c) 2011 by Kirill Shatrov
24
+ Copyright (c) 2011 by Kirill Shatrov, [Evrone.com](http://evrone.com/)
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Yandex
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  require 'omniauth/strategies/oauth2'
2
- require 'xmlsimple'
2
+ require 'json'
3
3
 
4
4
  module OmniAuth
5
5
  module Strategies
@@ -16,25 +16,18 @@ module OmniAuth
16
16
  :authorize_url => '/authorize'
17
17
  }
18
18
 
19
- uid do
20
- raw_info[:uid]
21
- end
19
+ uid { raw_info['id'] }
22
20
 
23
- info do
24
- {
25
- :nickname => raw_info[:name],
26
- :email => raw_info[:email],
27
- :name => raw_info[:name],
28
- :image => raw_info[:photo],
29
- :location => raw_info[:country],
30
- :urls => {
31
- 'Yandex' => raw_info[:yaru_profile]
32
- }
33
- }
21
+ extra do
22
+ prune!({:raw_info => raw_info})
34
23
  end
35
24
 
36
- extra do
37
- {:raw_info => raw_info}
25
+ info do
26
+ prune!({
27
+ 'nickname' => raw_info['display_name'],
28
+ 'email' => raw_info['default_email'],
29
+ 'name' => raw_info['real_name']
30
+ })
38
31
  end
39
32
 
40
33
  def callback_url
@@ -47,26 +40,19 @@ module OmniAuth
47
40
 
48
41
  private
49
42
 
43
+ def prune!(hash)
44
+ hash.delete_if do |_, value|
45
+ prune!(value) if value.is_a?(Hash)
46
+ value.nil? || (value.respond_to?(:empty?) && value.empty?)
47
+ end
48
+ end
49
+
50
50
  def raw_info
51
51
  @raw_info ||= begin
52
- # Get user info from Ya.ru API
53
- # http://api.yandex.ru/yaru/doc/ref/concepts/discovery.xml
54
- xml_data = access_token.get("https://api-yaru.yandex.ru/me/").body
55
- data = XmlSimple.xml_in(xml_data)
56
- {
57
- :uid => data["id"][0],
58
- :yaru_profile => data["link"][0]["href"],
59
- :photo => data["link"][2]["href"],
60
- :name => data["name"][0],
61
- :email => data["email"][0],
62
- :country => data["country"][0],
63
- :city => data["city"][0],
64
- :sex => data["sex"][0],
65
- :skype => data["skype"][0]
66
- }
52
+ # Get user info from Yandex.login API
53
+ JSON.parse access_token.get("https://login.yandex.ru/info?format=json").body
67
54
  end
68
55
  end
69
-
70
56
  end
71
57
  end
72
58
  end
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
6
6
  s.version = Omniauth::Yandex::VERSION
7
7
  s.authors = ["Kir Shatrov"]
8
8
  s.email = ["shatrov@me.com"]
9
- s.homepage = "https://github.com/kirs/omniauth-yandex"
9
+ s.homepage = "https://github.com/evrone/omniauth-yandex"
10
10
  s.summary = %q{OmniAuth strategy for Yandex.ru}
11
11
  s.description = %q{OmniAuth strategy for Yandex.ru}
12
12
 
@@ -19,5 +19,4 @@ Gem::Specification.new do |s|
19
19
 
20
20
  s.add_dependency 'omniauth', '~> 1.0'
21
21
  s.add_dependency 'omniauth-oauth2', '~> 1.0'
22
- s.add_dependency 'xml-simple'
23
22
  end
metadata CHANGED
@@ -1,59 +1,59 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: omniauth-yandex
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 2
9
+ version: 0.0.2
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - Kir Shatrov
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2011-11-26 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
16
+
17
+ date: 2012-10-21 00:00:00 +03:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: omniauth
16
- requirement: &70210863807100 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: '1.0'
22
- type: :runtime
23
22
  prerelease: false
24
- version_requirements: *70210863807100
25
- - !ruby/object:Gem::Dependency
26
- name: omniauth-oauth2
27
- requirement: &70210863805020 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
30
25
  - - ~>
31
- - !ruby/object:Gem::Version
32
- version: '1.0'
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 0
30
+ version: "1.0"
33
31
  type: :runtime
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: omniauth-oauth2
34
35
  prerelease: false
35
- version_requirements: *70210863805020
36
- - !ruby/object:Gem::Dependency
37
- name: xml-simple
38
- requirement: &70210863803400 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: '0'
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ segments:
41
+ - 1
42
+ - 0
43
+ version: "1.0"
44
44
  type: :runtime
45
- prerelease: false
46
- version_requirements: *70210863803400
45
+ version_requirements: *id002
47
46
  description: OmniAuth strategy for Yandex.ru
48
- email:
47
+ email:
49
48
  - shatrov@me.com
50
49
  executables: []
50
+
51
51
  extensions: []
52
+
52
53
  extra_rdoc_files: []
53
- files:
54
+
55
+ files:
54
56
  - .gitignore
55
- - .rspec
56
- - .travis.yml
57
57
  - Gemfile
58
58
  - README.md
59
59
  - Rakefile
@@ -61,28 +61,35 @@ files:
61
61
  - lib/omniauth-yandex/version.rb
62
62
  - lib/omniauth/strategies/yandex.rb
63
63
  - omniauth-yandex.gemspec
64
- homepage: https://github.com/kirs/omniauth-yandex
64
+ has_rdoc: true
65
+ homepage: https://github.com/evrone/omniauth-yandex
65
66
  licenses: []
67
+
66
68
  post_install_message:
67
69
  rdoc_options: []
68
- require_paths:
70
+
71
+ require_paths:
69
72
  - lib
70
- required_ruby_version: !ruby/object:Gem::Requirement
71
- none: false
72
- requirements:
73
- - - ! '>='
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- required_rubygems_version: !ruby/object:Gem::Requirement
77
- none: false
78
- requirements:
79
- - - ! '>='
80
- - !ruby/object:Gem::Version
81
- version: '0'
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ segments:
85
+ - 0
86
+ version: "0"
82
87
  requirements: []
88
+
83
89
  rubyforge_project: omniauth-yandex
84
- rubygems_version: 1.8.10
90
+ rubygems_version: 1.3.6
85
91
  signing_key:
86
92
  specification_version: 3
87
93
  summary: OmniAuth strategy for Yandex.ru
88
94
  test_files: []
95
+
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --colour
@@ -1,5 +0,0 @@
1
- rvm:
2
- - 1.8.7
3
- - 1.9.2
4
- - 1.9.3
5
- - ree