social 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/social/config.rb +3 -11
- data/lib/social/config/ok.rb +11 -2
- data/lib/social/config/vk.rb +8 -2
- data/lib/social/version.rb +1 -1
- data/spec/lib/social_spec.rb +12 -2
- metadata +17 -17
data/lib/social/config.rb
CHANGED
@@ -1,17 +1,9 @@
|
|
1
1
|
module Social
|
2
2
|
class Config
|
3
3
|
|
4
|
-
#@@network_name = nil
|
5
|
-
|
6
|
-
#def self.included(network)
|
7
|
-
# require 'pry'
|
8
|
-
# binding.pry
|
9
|
-
# network.send(:include, InstanceMethods)
|
10
|
-
# @@network_name = network.name.split('::').last.downcase
|
11
|
-
#end
|
12
|
-
|
13
4
|
def initialize(network_name)
|
14
5
|
@network_name = network_name
|
6
|
+
@config_file_data = {}
|
15
7
|
end
|
16
8
|
|
17
9
|
def network_name
|
@@ -19,7 +11,7 @@ module Social
|
|
19
11
|
end
|
20
12
|
|
21
13
|
def config
|
22
|
-
@config_data ||= load_config_file
|
14
|
+
@config_data ||= load_config_file[@network_name]
|
23
15
|
end
|
24
16
|
|
25
17
|
def config_file_path=(new_path)
|
@@ -43,7 +35,7 @@ module Social
|
|
43
35
|
end
|
44
36
|
|
45
37
|
def load_config_file
|
46
|
-
YAML.load_file(config_file_path).with_indifferent_access
|
38
|
+
@config_file_data[config_file_path] ||= YAML.load_file(config_file_path).with_indifferent_access
|
47
39
|
end
|
48
40
|
|
49
41
|
|
data/lib/social/config/ok.rb
CHANGED
@@ -1,15 +1,24 @@
|
|
1
1
|
module Social
|
2
2
|
class Config
|
3
3
|
module Ok
|
4
|
+
|
4
5
|
def config
|
6
|
+
|
5
7
|
unless @config
|
6
8
|
@env = ENV['APP_ENV'] || ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development'
|
7
|
-
@config_ins = Social::Config.new(
|
8
|
-
@config = @config_ins.config[
|
9
|
+
@config_ins = Social::Config.new(:ok)
|
10
|
+
@config = @config_ins.config[@env]
|
9
11
|
end
|
10
12
|
|
11
13
|
@config
|
12
14
|
end
|
15
|
+
|
16
|
+
def safe_config(auth_params = {})
|
17
|
+
auth_params.merge \
|
18
|
+
:api_server => Social::Network(:ok).config[:api_server],
|
19
|
+
:application_key => Social::Network(:ok).config[:application_key],
|
20
|
+
:logged_user_id => auth_params['uid']
|
21
|
+
end
|
13
22
|
end
|
14
23
|
end
|
15
24
|
end
|
data/lib/social/config/vk.rb
CHANGED
@@ -6,13 +6,19 @@ module Social
|
|
6
6
|
|
7
7
|
unless @config
|
8
8
|
@env = ENV['APP_ENV'] || ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development'
|
9
|
-
@config_ins = Social::Config.new(
|
10
|
-
@config = @config_ins.config[
|
9
|
+
@config_ins = Social::Config.new(:vk)
|
10
|
+
@config = @config_ins.config[@env]
|
11
11
|
end
|
12
12
|
|
13
13
|
@config
|
14
14
|
end
|
15
15
|
|
16
|
+
def safe_config(auth_params = {})
|
17
|
+
auth_params.merge \
|
18
|
+
:app_id => Social::Network(:vk).config['app_id'],
|
19
|
+
:logged_user_id => auth_params['uid']
|
20
|
+
end
|
21
|
+
|
16
22
|
end
|
17
23
|
end
|
18
24
|
end
|
data/lib/social/version.rb
CHANGED
data/spec/lib/social_spec.rb
CHANGED
@@ -13,15 +13,25 @@ describe Social do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "must load config to vk" do
|
16
|
-
|
16
|
+
Social::Network(:vk).config.should_not be_nil
|
17
17
|
Social::Network(:vk).config['key'].should_not be_nil
|
18
18
|
Social::Network(:vk).config['app_id'].should_not be_nil
|
19
19
|
end
|
20
20
|
|
21
|
-
it "must load config to
|
21
|
+
it "must load config to ok" do
|
22
22
|
Social::Network(:ok).config.should_not be_nil
|
23
23
|
Social::Network(:ok).config['api_server'].should_not be_nil
|
24
24
|
Social::Network(:ok).config['application_key'].should_not be_nil
|
25
25
|
Social::Network(:ok).config['secret_key'].should_not be_nil
|
26
26
|
end
|
27
|
+
|
28
|
+
it "valid safe config data for vk" do
|
29
|
+
avalible_keys = [ :app_id , :logged_user_id ]
|
30
|
+
Social::Network(:vk).safe_config.keys.should =~ avalible_keys
|
31
|
+
end
|
32
|
+
|
33
|
+
it "valid safe config data for ok" do
|
34
|
+
avalible_keys = [ :api_server , :application_key, :logged_user_id ]
|
35
|
+
Social::Network(:ok).safe_config.keys.should =~ avalible_keys
|
36
|
+
end
|
27
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: social
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-03-24 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec-core
|
16
|
-
requirement: &
|
16
|
+
requirement: &70292337319380 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '2.0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70292337319380
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec-expectations
|
27
|
-
requirement: &
|
27
|
+
requirement: &70292337318880 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '2.0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70292337318880
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rack
|
38
|
-
requirement: &
|
38
|
+
requirement: &70292337318420 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.4.1
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70292337318420
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rack-test
|
49
|
-
requirement: &
|
49
|
+
requirement: &70292337317960 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.6.1
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70292337317960
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rr
|
60
|
-
requirement: &
|
60
|
+
requirement: &70292337317500 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '1.0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70292337317500
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: pry
|
71
|
-
requirement: &
|
71
|
+
requirement: &70292337316980 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 0.9.8.4
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70292337316980
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: activesupport
|
82
|
-
requirement: &
|
82
|
+
requirement: &70292337316460 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 3.1.3
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70292337316460
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: i18n
|
93
|
-
requirement: &
|
93
|
+
requirement: &70292337310040 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: 0.6.0
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70292337310040
|
102
102
|
description: ! "This is social networks api wrapper and authorization tools for social
|
103
103
|
applications. \n Now it is a compilation of code from various projects in production.
|
104
104
|
Without tests. =( NOT RECOMMENDED USE IN PRODUCTION."
|