ucenter 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/lib/ucenter.rb +1 -0
- data/lib/ucenter/client.rb +5 -0
- data/lib/ucenter/config.rb +96 -0
- data/lib/ucenter/interface/base.rb +17 -0
- data/lib/ucenter/interface/user.rb +30 -0
- data/lib/ucenter/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d1dcc7055c7ee28d0f4fb05b65b4a994215808a
|
4
|
+
data.tar.gz: 1090fb5d8c8f327654747e0af5325c288d8b05a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 713c51920ffb18ca26c9d4fa588226430f3e08953d66c5191df36c19ccf21ef85271ff1a122195f3b3ae87bc51a2048b24489045451e58cbbe27374feb8cd77c
|
7
|
+
data.tar.gz: d51c837df83c907a6da7ddbe52e482802746134bcd25cfbcc9f2e2996bd8e153450eb36679f504797b490420f90efae0481fdf7f83ee19f3b09dbd589dbeb3bc
|
data/Gemfile
CHANGED
data/lib/ucenter.rb
CHANGED
data/lib/ucenter/client.rb
CHANGED
data/lib/ucenter/config.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
module Ucenter
|
2
2
|
module Config
|
3
3
|
|
4
|
+
def self.uc_connect=(val)
|
5
|
+
@@uc_connect = val
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.uc_connect
|
9
|
+
@@uc_connect
|
10
|
+
end
|
11
|
+
|
4
12
|
def self.uc_key=(val)
|
5
13
|
@@uc_key = val
|
6
14
|
end
|
@@ -24,5 +32,93 @@ module Ucenter
|
|
24
32
|
def self.uc_api
|
25
33
|
@@uc_api
|
26
34
|
end
|
35
|
+
|
36
|
+
def self.uc_charset=(val)
|
37
|
+
@@uc_charset = val
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.uc_charset
|
41
|
+
@@uc_charset
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.uc_ip=(val)
|
45
|
+
@@uc_ip = val
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.uc_ip
|
49
|
+
@@uc_ip
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.uc_ppp=(val)
|
53
|
+
@@uc_ppp = val
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.uc_ppp
|
57
|
+
@@uc_ppp
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.uc_dbhost=(val)
|
61
|
+
@@uc_dbhost = val
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.uc_dbhost
|
65
|
+
@@uc_dbhost
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.uc_dbuser=(val)
|
69
|
+
@@uc_dbuser = val
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.uc_dbuser
|
73
|
+
@@uc_dbuser
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.uc_dbpw=(val)
|
77
|
+
@@uc_dbpw = val
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.uc_dbpw
|
81
|
+
@@uc_dbpw
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.uc_dbname=(val)
|
85
|
+
@@uc_dbname = val
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.uc_dbname
|
89
|
+
@@uc_dbname
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.uc_dbcharset=(val)
|
93
|
+
@@uc_dbcharset = val
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.uc_dbcharset
|
97
|
+
@@uc_dbcharset
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.uc_dbtablepre=(val)
|
101
|
+
@@uc_dbtablepre = val
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.uc_dbtablepre
|
105
|
+
@@uc_dbtablepre
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.uc_dbconnect=(val)
|
109
|
+
@@uc_dbconnect = val
|
110
|
+
end
|
111
|
+
|
112
|
+
def self.uc_dbconnect
|
113
|
+
@@uc_dbconnect
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.uc_ip=(val)
|
117
|
+
@@uc_ip = val
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.uc_ip
|
121
|
+
@@uc_ip
|
122
|
+
end
|
27
123
|
end
|
28
124
|
end
|
@@ -6,6 +6,23 @@ module Ucenter
|
|
6
6
|
@client = client
|
7
7
|
end
|
8
8
|
|
9
|
+
def get(path, opts={}, &block)
|
10
|
+
request(:get, path, opts, &block)
|
11
|
+
end
|
12
|
+
|
13
|
+
def post(path, opts={}, &block)
|
14
|
+
request(:post, path, opts, &block)
|
15
|
+
end
|
16
|
+
|
17
|
+
def db_client
|
18
|
+
config = Hash.new
|
19
|
+
config[:host] = Ucenter::Config.uc_dbhost unless Ucenter::Config.uc_dbhost.nil?
|
20
|
+
config[:username] = Ucenter::Config.uc_dbuser unless Ucenter::Config.uc_dbuser.nil?
|
21
|
+
config[:password] = Ucenter::Config.uc_dbpw unless Ucenter::Config.uc_dbpw.nil?
|
22
|
+
config[:database] = Ucenter::Config.uc_dbname unless Ucenter::Config.uc_dbname.nil?
|
23
|
+
config[:encoding] = Ucenter::Config.uc_dbcharset unless Ucenter::Config.uc_dbcharset.nil?
|
24
|
+
Mysql2::Client.new(config)
|
25
|
+
end
|
9
26
|
|
10
27
|
end
|
11
28
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Ucenter
|
2
|
+
module Interface
|
3
|
+
class User < Base
|
4
|
+
|
5
|
+
def get_user(username, is_uid = FALSE)
|
6
|
+
if is_uid == 1
|
7
|
+
data = get_user_by_uid(username)
|
8
|
+
elsif is_uid == 2
|
9
|
+
data= get_user_by_email(username)
|
10
|
+
else
|
11
|
+
data = get_user_by_username(username)
|
12
|
+
end
|
13
|
+
data
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_user_by_username(username)
|
17
|
+
db_client.query("SELECT * FROM #{Ucenter::Config.uc_dbtablepre}members WHERE username='#{username}'").to_a[0]
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_user_by_uid(username)
|
21
|
+
db_client.query("SELECT * FROM #{Ucenter::Config.uc_dbtablepre}members WHERE uid='#{username}'").to_a[0]
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_user_by_email(username)
|
25
|
+
db_client.query("SELECT * FROM #{Ucenter::Config.uc_dbtablepre}members WHERE email='#{username}'").to_a[0]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
data/lib/ucenter/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ucenter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Willin Wang
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- lib/ucenter/config.rb
|
55
55
|
- lib/ucenter/interface/authcode.rb
|
56
56
|
- lib/ucenter/interface/base.rb
|
57
|
+
- lib/ucenter/interface/user.rb
|
57
58
|
- lib/ucenter/interface/utility.rb
|
58
59
|
- lib/ucenter/version.rb
|
59
60
|
- ucenter.gemspec
|