omniauth-vkontakte 1.0.1 → 1.0.2

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.
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # OmniAuth VKontakte
2
2
 
3
- This is the unofficial VKontakte strategy for authenticating to VKontakte. To
4
- use it, you'll need to sign up for an OAuth2 Application ID and Secret
3
+ This is the unofficial OmniAuth strategy for authenticating to VKontakte via OAuth.
4
+ To use it, you'll need to sign up for an OAuth2 Application ID and Secret
5
5
  on the [Vkontakte Developers Page](http://vk.com/developers.php).
6
6
 
7
7
  ## Basic Usage
@@ -10,6 +10,13 @@ on the [Vkontakte Developers Page](http://vk.com/developers.php).
10
10
  provider :vkontakte, ENV['API_KEY'], ENV['API_SECRET']
11
11
  end
12
12
 
13
+ ## Ruby
14
+
15
+ Tested with the following Ruby versions:
16
+
17
+ - MRI 1.9.3
18
+ - MRI 1.8.7
19
+
13
20
  ## License
14
21
 
15
22
  Copyright (c) 2011 Anton Maminov.
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Vkontakte
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  end
@@ -31,7 +31,8 @@ module OmniAuth
31
31
  :nickname => raw_info['nickname'],
32
32
  :first_name => raw_info['first_name'],
33
33
  :last_name => raw_info['last_name'],
34
- :image => raw_info['image'],
34
+ :image => raw_info['photo'],
35
+ :location => location,
35
36
  :urls => {
36
37
  'Vkontakte' => "http://vk.com/#{raw_info['domain']}"
37
38
  }
@@ -44,9 +45,36 @@ module OmniAuth
44
45
 
45
46
  def raw_info
46
47
  # http://vkontakte.ru/developers.php?o=-17680044&p=Description+of+Fields+of+the+fields+Parameter
47
- fields = ['uid', 'first_name', 'last_name', 'nickname', 'domain', 'sex', 'bdate', 'city', 'country', 'timezone', 'photo', 'photo_big']
48
- access_token.get('/method/getProfiles', :params => { :uid => uid, :fields => fields.join(',') }).parsed["response"].first
48
+ fields = ['uid', 'first_name', 'last_name', 'nickname', 'sex', 'city', 'country', 'online', 'bdate', 'photo', 'photo_big', 'domain']
49
+ @raw_info ||= access_token.get('/method/getProfiles', :params => { :uid => uid, :fields => fields.join(',') }).parsed["response"].first
49
50
  end
51
+
52
+ private
53
+
54
+ # http://vkontakte.ru/developers.php?o=-17680044&p=getCountries
55
+ def get_country
56
+ if raw_info['country'] && raw_info['country'] != "0"
57
+ country = access_token.get('/method/getCountries', :params => { :cids => raw_info['country'] }).parsed['response']
58
+ return country.first ? country.first['name'] : ''
59
+ else
60
+ return ''
61
+ end
62
+ end
63
+
64
+ # http://vkontakte.ru/developers.php?o=-17680044&p=getCities
65
+ def get_city
66
+ if raw_info['city'] && raw_info['city'] != "0"
67
+ city = access_token.get('/method/getCities', :params => { :cids => raw_info['city'] }).parsed['response']
68
+ return city.first ? city.first['name'] : ''
69
+ else
70
+ return ''
71
+ end
72
+ end
73
+
74
+ def location
75
+ @location ||= "#{get_country}, #{get_city}"
76
+ end
77
+
50
78
  end
51
79
  end
52
80
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-vkontakte
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-05 00:00:00.000000000 Z
12
+ date: 2011-11-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: omniauth
16
- requirement: &84808660 !ruby/object:Gem::Requirement
16
+ requirement: &84707940 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *84808660
24
+ version_requirements: *84707940
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: omniauth-oauth2
27
- requirement: &84808410 !ruby/object:Gem::Requirement
27
+ requirement: &84707690 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '1.0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *84808410
35
+ version_requirements: *84707690
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: multi_json
38
- requirement: &84808150 !ruby/object:Gem::Requirement
38
+ requirement: &84707430 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *84808150
46
+ version_requirements: *84707430
47
47
  description: Unofficial VKontakte strategy for OmniAuth 1.0
48
48
  email:
49
49
  - anton.linux@gmail.com