gitcontacts 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/gitcontacts.gemspec +1 -1
- data/lib/gitcontacts/Request.rb +2 -1
- data/lib/gitcontacts/User.rb +18 -24
- data/lib/gitcontacts/version.rb +1 -1
- data/lib/gitcontacts.rb +8 -4
- metadata +2 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 903fd08dcfe122a1461ba4e05d0b5651ce5acfeb
|
4
|
+
data.tar.gz: 58d9cdeb6f50200ecad553599c9e757b52fa911b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdce2b3be1b0275b5ea4dcc16e751a3d8e9ea27e7ab26101d0f02641435a8cf6a54b7a13ed215f75bd1d477cf0c620bd86f354517a4827cc00de1da235dd0e3f
|
7
|
+
data.tar.gz: ef90fb5d3d632c99f376c1603f76179a0332864d2cc068113ba03fdd83dcda97b662b8cbf5f41ca3ea81976896b21a79474adab83cc6bf3297a54dbba66e3e92
|
data/gitcontacts.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency "redis", '~> 3.2'
|
22
|
-
spec.add_dependency "gitdb", '~> 0.1
|
22
|
+
spec.add_dependency "gitdb", '~> 0.1.3'
|
23
23
|
spec.add_dependency "redis-objects", "~> 1.0"
|
24
24
|
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.7"
|
data/lib/gitcontacts/Request.rb
CHANGED
data/lib/gitcontacts/User.rb
CHANGED
@@ -2,17 +2,13 @@ module GitContacts
|
|
2
2
|
|
3
3
|
class User
|
4
4
|
|
5
|
-
def self::exist?
|
6
|
-
true if UserObject::exist?(
|
7
|
-
end
|
8
|
-
|
9
|
-
def self::email_to_uid email
|
10
|
-
|
5
|
+
def self::exist? email
|
6
|
+
true if UserObject::exist?(email)
|
11
7
|
end
|
12
8
|
|
13
9
|
def self::create hash
|
14
10
|
# some keys are optional
|
15
|
-
if hash.keys.include?(:email) && hash.keys.include?(:password)
|
11
|
+
if hash.keys.include?(:email) && hash.keys.include?(:password) && !User::exist?(hash[:email])
|
16
12
|
obj = UserObject.new
|
17
13
|
obj.email = hash[:email]
|
18
14
|
obj.password = hash[:password]
|
@@ -20,8 +16,8 @@ module GitContacts
|
|
20
16
|
end
|
21
17
|
end
|
22
18
|
|
23
|
-
def initialize
|
24
|
-
@obj = UserObject::access
|
19
|
+
def initialize email
|
20
|
+
@obj = UserObject::access email
|
25
21
|
end
|
26
22
|
|
27
23
|
def getuid
|
@@ -87,28 +83,26 @@ module GitContacts
|
|
87
83
|
"user_object:"
|
88
84
|
end
|
89
85
|
|
90
|
-
def self::exist?
|
91
|
-
true if redis.keys(key_prefix+
|
86
|
+
def self::exist? email
|
87
|
+
true if redis.keys(key_prefix+email+':*').count > 0
|
92
88
|
end
|
93
89
|
|
94
|
-
def self::access
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
obj
|
103
|
-
end
|
90
|
+
def self::access email
|
91
|
+
obj = allocate
|
92
|
+
obj.set_email email
|
93
|
+
obj.set_uid Redis::Value.new(key_prefix+id+':uid')
|
94
|
+
obj.set_password Redis::Value.new(key_prefix+id+':password')
|
95
|
+
obj.set_contacts Redis::Set.new(key_prefix+id+':contacts')
|
96
|
+
obj.set_requests Redis::Set.new(key_prefix+id+':requests')
|
97
|
+
obj
|
104
98
|
end
|
105
99
|
|
106
100
|
def initialize
|
107
|
-
@uid = Digest::SHA1.hexdigest
|
101
|
+
@uid = Digest::SHA1.hexdigest(Time.now.to_s + rand(10000))
|
108
102
|
end
|
109
103
|
|
110
104
|
def id
|
111
|
-
@
|
105
|
+
@email
|
112
106
|
end
|
113
107
|
|
114
108
|
def set_uid uid
|
@@ -133,4 +127,4 @@ module GitContacts
|
|
133
127
|
|
134
128
|
end
|
135
129
|
|
136
|
-
end
|
130
|
+
end
|
data/lib/gitcontacts/version.rb
CHANGED
data/lib/gitcontacts.rb
CHANGED
@@ -21,9 +21,9 @@ module GitContacts
|
|
21
21
|
User::create hash
|
22
22
|
end
|
23
23
|
|
24
|
-
def password_valid
|
25
|
-
if user = User.new(
|
26
|
-
user.password_correct? Digest::SHA1.hexdigest password
|
24
|
+
def password_valid? email, password
|
25
|
+
if user = User.new(email)
|
26
|
+
user if user.password_correct? Digest::SHA1.hexdigest password
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -58,6 +58,7 @@ module GitContacts
|
|
58
58
|
#return unless GitContacts::relation_valid? operator gid
|
59
59
|
contacts = Gitdb::Contacts.new operator
|
60
60
|
contacts.create name
|
61
|
+
contacts.getmeta[:gid]
|
61
62
|
end
|
62
63
|
|
63
64
|
def edit_contacts_meta operator, gid, new_meta
|
@@ -169,10 +170,11 @@ module GitContacts
|
|
169
170
|
# create a rqeuest
|
170
171
|
req = Request.new qid
|
171
172
|
if req.auto_merge? operator
|
172
|
-
req.allow operator
|
173
173
|
Request::delete qid
|
174
174
|
# here should return card_id if success
|
175
|
+
return req.allow operator
|
175
176
|
end
|
177
|
+
true
|
176
178
|
end
|
177
179
|
|
178
180
|
def edit_contacts_card operator, gid, card_id, payload
|
@@ -183,6 +185,7 @@ module GitContacts
|
|
183
185
|
req.allow operator
|
184
186
|
Request::delete qid
|
185
187
|
end
|
188
|
+
true
|
186
189
|
end
|
187
190
|
|
188
191
|
def delete_contacts_card operator, gid, card_id
|
@@ -193,6 +196,7 @@ module GitContacts
|
|
193
196
|
req.allow operator
|
194
197
|
Request::delete qid
|
195
198
|
end
|
199
|
+
true
|
196
200
|
end
|
197
201
|
|
198
202
|
def get_contacts_users operator, gid
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitcontacts
|
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
|
- AustinChou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -29,9 +29,6 @@ dependencies:
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0.1'
|
34
|
-
- - ">="
|
35
32
|
- !ruby/object:Gem::Version
|
36
33
|
version: 0.1.3
|
37
34
|
type: :runtime
|
@@ -39,9 +36,6 @@ dependencies:
|
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
38
|
- - "~>"
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '0.1'
|
44
|
-
- - ">="
|
45
39
|
- !ruby/object:Gem::Version
|
46
40
|
version: 0.1.3
|
47
41
|
- !ruby/object:Gem::Dependency
|