social 0.0.11 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +72 -40
- data/lib/social.rb +65 -30
- data/lib/social/balance.rb +1 -14
- data/lib/social/config/ok.rb +16 -18
- data/lib/social/config/vk.rb +15 -17
- data/lib/social/determinant.rb +4 -0
- data/lib/social/determinant/request_param.rb +56 -0
- data/lib/social/determinant/social_prefix.rb +81 -0
- data/lib/social/env.rb +21 -15
- data/lib/social/network.rb +9 -1
- data/lib/social/network/base.rb +60 -9
- data/lib/social/network/graph.rb +1 -40
- data/lib/social/network/graph/ok.rb +1 -5
- data/lib/social/network/graph/ok/base.rb +50 -56
- data/lib/social/network/graph/ok/notification.rb +9 -15
- data/lib/social/network/graph/ok/user.rb +61 -67
- data/lib/social/network/graph/tail.rb +14 -20
- data/lib/social/network/graph/vk.rb +1 -5
- data/lib/social/network/graph/vk/base.rb +27 -33
- data/lib/social/network/graph/vk/notification.rb +11 -17
- data/lib/social/network/graph/vk/user.rb +55 -61
- data/lib/social/network/ok.rb +9 -17
- data/lib/social/network/stub.rb +2 -7
- data/lib/social/network/vk.rb +9 -17
- data/lib/social/version.rb +1 -1
- data/social.gemspec +1 -0
- data/spec/lib/social/ok_api_spec.rb +8 -8
- data/spec/lib/social/vk_api_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -4
- metadata +80 -48
- data/lib/social/auth.rb +0 -4
- data/lib/social/auth/controller.rb +0 -144
- data/lib/social/builder.rb +0 -22
- data/lib/social/cache.rb +0 -26
- data/lib/social/helper.rb +0 -4
- data/lib/social/helper/controller.rb +0 -43
- data/lib/social/helper/model.rb +0 -61
- data/lib/social/network/params.rb +0 -31
- data/lib/social/provider.rb +0 -42
data/lib/social/helper.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
# Add helper methods for Social in base controller class
|
2
|
-
module Social
|
3
|
-
module Helper
|
4
|
-
module Controller
|
5
|
-
|
6
|
-
def self.included(base)
|
7
|
-
base.instance_eval do
|
8
|
-
helper_method :current_social_type, :current_social_type_id, :current_social_prefix
|
9
|
-
before_filter :init_social_env
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
# Helper, returned social type id from request
|
14
|
-
# (controller, view).current_social_type_id
|
15
|
-
def current_social_type_id
|
16
|
-
@current_social_type_id ||= params[:soc_id]
|
17
|
-
end
|
18
|
-
|
19
|
-
# Helper, returned social type from request
|
20
|
-
# (controller, view).current_social_type
|
21
|
-
def current_social_type
|
22
|
-
@current_social_type ||= params[:soc_type]
|
23
|
-
end
|
24
|
-
|
25
|
-
# Helper, returned social type prefix from request
|
26
|
-
# (controller, view).current_social_type_prefix
|
27
|
-
def current_social_prefix
|
28
|
-
@current_social_prefix ||= params[:soc_prefix]
|
29
|
-
end
|
30
|
-
|
31
|
-
protected
|
32
|
-
|
33
|
-
def init_social_env
|
34
|
-
#Social.current_id = params[:soc_id]
|
35
|
-
#Social.current_type = params[:soc_type]
|
36
|
-
#Social.current_prefix = params[:soc_prefix]
|
37
|
-
|
38
|
-
Social::Env.init(params)
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
data/lib/social/helper/model.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
# Add helper methods for Social in user model class (Active record)
|
2
|
-
module Social
|
3
|
-
module Helper
|
4
|
-
module Model
|
5
|
-
|
6
|
-
def self.included(base)
|
7
|
-
base.instance_eval do
|
8
|
-
attr_accessor :auth_params
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
# Alias for model.current_social_type
|
13
|
-
# model.current_provider String
|
14
|
-
# @params social_type_id = nil
|
15
|
-
def current_provider(social_type_id = nil)
|
16
|
-
current_social_type(social_type_id)
|
17
|
-
end
|
18
|
-
|
19
|
-
# Return current social type or social type by social_type_id
|
20
|
-
# model.current_social_type String
|
21
|
-
# @params social_type_id = nil
|
22
|
-
def current_social_type(social_type_id = nil)
|
23
|
-
if social_type_id
|
24
|
-
@current_provider = Social.type_by_id(social_type_id)
|
25
|
-
elsif auth_params && auth_params[:social_type]
|
26
|
-
@current_provider = auth_params[:social_type]
|
27
|
-
else
|
28
|
-
@current_provider = Social::Env.type
|
29
|
-
end
|
30
|
-
|
31
|
-
@current_provider
|
32
|
-
end
|
33
|
-
|
34
|
-
# Return current social type id
|
35
|
-
# model.current_social_type String
|
36
|
-
def current_social_type_id()
|
37
|
-
unless @current_social_type_id
|
38
|
-
@current_social_type_id = Social::Env.id
|
39
|
-
end
|
40
|
-
|
41
|
-
@current_social_type_id
|
42
|
-
end
|
43
|
-
|
44
|
-
# Make standart hash (for js) from model data
|
45
|
-
# model.to_hash hash
|
46
|
-
# @params params = {}
|
47
|
-
def to_hash(params = {})
|
48
|
-
{
|
49
|
-
:id => id,
|
50
|
-
:first_name => first_name,
|
51
|
-
:last_name => last_name,
|
52
|
-
:uid => social_references.last.uid,
|
53
|
-
:name => "#{first_name} #{last_name}",
|
54
|
-
:gender => (male? ? 'male' : 'female'),
|
55
|
-
:birthday => birthdate
|
56
|
-
}
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Social
|
2
|
-
module Network
|
3
|
-
module Params
|
4
|
-
|
5
|
-
def params()
|
6
|
-
@params
|
7
|
-
end
|
8
|
-
|
9
|
-
def params!(params)
|
10
|
-
@params = params
|
11
|
-
self
|
12
|
-
end
|
13
|
-
|
14
|
-
def param(key)
|
15
|
-
@params[key]
|
16
|
-
end
|
17
|
-
|
18
|
-
def param!(key, value)
|
19
|
-
@params[key] = value
|
20
|
-
self
|
21
|
-
end
|
22
|
-
|
23
|
-
protected
|
24
|
-
|
25
|
-
def init_params(params)
|
26
|
-
@params = params.is_a?(Hash) ? params : {}
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/lib/social/provider.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
module Social
|
2
|
-
class Provider
|
3
|
-
def self.build(prefix)
|
4
|
-
|
5
|
-
klass = Class.new do
|
6
|
-
|
7
|
-
class << self
|
8
|
-
attr_accessor :prefix
|
9
|
-
end
|
10
|
-
|
11
|
-
def initialize(app)
|
12
|
-
@app = app
|
13
|
-
end
|
14
|
-
|
15
|
-
def call(env)
|
16
|
-
request = Rack::Request.new(env)
|
17
|
-
|
18
|
-
prefix = self.class.prefix
|
19
|
-
type = Social.type_by_prefix(prefix)
|
20
|
-
id = Social.id_by_type(type)
|
21
|
-
|
22
|
-
request.GET['social_env'] = {
|
23
|
-
'prefix' => prefix,
|
24
|
-
'type' => type,
|
25
|
-
'id' => id
|
26
|
-
}
|
27
|
-
|
28
|
-
# Old
|
29
|
-
request.GET['soc_prefix'] = prefix
|
30
|
-
request.GET['soc_type'] = type
|
31
|
-
request.GET['soc_id'] = id
|
32
|
-
|
33
|
-
@app.call(request.env)
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
klass.prefix = prefix
|
39
|
-
klass
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|