gitdb 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -9
- data/lib/gitdb/Card.rb +13 -39
- data/lib/gitdb/Contacts.rb +10 -14
- data/lib/gitdb/util.rb +1 -1
- data/lib/gitdb/version.rb +1 -1
- data/lib/gitdb.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd555baba7939ba328863a24472a914e7d9eb436
|
4
|
+
data.tar.gz: d99302d2a081c812e8ab8757016cfd1acc79f24d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06cf2a433f5c1734784a91cdf2190618cce47ddf4d9186e19cc42a6b779ee045c72ae29f973ed003e28eeaf6204e59da825c7358c520589e3ed0b8ae2af0d034
|
7
|
+
data.tar.gz: 906d0588f6c7206b39bbdac91e70da37f0f938b9c62f238de946a8b18194a483b509c0fc85bd8a4b8413985af3be82e5329990dfcbe29ef745b1f87f88d603b9
|
data/README.md
CHANGED
@@ -30,19 +30,19 @@ Or install it yourself as:
|
|
30
30
|
|
31
31
|
+ class method: `exist?(gid)`
|
32
32
|
|
33
|
-
##### instance: `Gitdb::Contacts.new(
|
33
|
+
##### instance: `Gitdb::Contacts.new(user_id)`
|
34
34
|
|
35
35
|
+ property: `repo`
|
36
|
-
+ method: `exist?(
|
37
|
-
+ method: `create(
|
38
|
-
+ method: `access(
|
36
|
+
+ method: `exist?(contacts_id)`
|
37
|
+
+ method: `create(contacts_name)`
|
38
|
+
+ method: `access(contacts_id)`
|
39
39
|
+ method: `getmeta`
|
40
40
|
+ method: `setmeta(Hash)`
|
41
41
|
+ method: `get_all_cards`
|
42
|
-
+ method: `get_card_by_id(
|
42
|
+
+ method: `get_card_by_id(card_id)`
|
43
43
|
+ method: `read_change_history`
|
44
|
-
+ method: `revert_to(sha,
|
45
|
-
+ method: `make_a_commit(
|
44
|
+
+ method: `revert_to(sha, {})`
|
45
|
+
+ method: `make_a_commit({})`
|
46
46
|
|
47
47
|
#### Class: `Gitdb::Card`
|
48
48
|
|
@@ -50,8 +50,8 @@ Or install it yourself as:
|
|
50
50
|
|
51
51
|
##### instance: `Gitdb::Card.new(repo)`
|
52
52
|
|
53
|
-
+ method: `create(
|
54
|
-
+ method: `access(
|
53
|
+
+ method: `create(user_id)`
|
54
|
+
+ method: `access(card_id)`
|
55
55
|
+ method: `format_card(id, uid)`
|
56
56
|
+ method: `getdata`
|
57
57
|
+ method: `setdata(Hash)`
|
data/lib/gitdb/Card.rb
CHANGED
@@ -3,7 +3,7 @@ module Gitdb
|
|
3
3
|
class Card
|
4
4
|
|
5
5
|
# 线程锁
|
6
|
-
@@lock =
|
6
|
+
@@lock = Mutex.new
|
7
7
|
|
8
8
|
def initialize repo
|
9
9
|
@repo = repo
|
@@ -39,25 +39,19 @@ module Gitdb
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def create uid
|
42
|
-
# 等待资源可用
|
43
|
-
loop do
|
44
|
-
break unless @@lock
|
45
|
-
end
|
46
|
-
# 锁定资源
|
47
|
-
@@lock = true
|
48
|
-
|
49
|
-
# 生成唯一的名片id
|
50
|
-
while exist?(@id = Gitil::generate_code(4))
|
51
|
-
end
|
52
|
-
# 记录名片创建者id
|
53
|
-
@uid = uid
|
54
|
-
# 用默认格式初始化名片可读内容
|
55
|
-
@content = format_card @id, @uid
|
56
|
-
# 添加到暂存区
|
57
|
-
add_to_stage @id, JSON.pretty_generate(@content)
|
58
42
|
|
59
|
-
#
|
60
|
-
@@lock
|
43
|
+
# 同步信号量
|
44
|
+
@@lock.synchronize {
|
45
|
+
# 生成唯一的名片id
|
46
|
+
while exist?(@id = Gitil::generate_code(4))
|
47
|
+
end
|
48
|
+
# 记录名片创建者id
|
49
|
+
@uid = uid
|
50
|
+
# 用默认格式初始化名片可读内容
|
51
|
+
@content = format_card @id, @uid
|
52
|
+
# 添加到暂存区
|
53
|
+
add_to_stage @id, JSON.pretty_generate(@content)
|
54
|
+
}
|
61
55
|
|
62
56
|
# 返回Card实例
|
63
57
|
self
|
@@ -77,26 +71,6 @@ module Gitdb
|
|
77
71
|
nil
|
78
72
|
end
|
79
73
|
end
|
80
|
-
|
81
|
-
def self::getdata repo, id
|
82
|
-
Card.new(repo).access(id).getdata
|
83
|
-
end
|
84
|
-
|
85
|
-
def self::setdata repo, id, hash
|
86
|
-
Card.new(repo).access(id).setdata hash
|
87
|
-
end
|
88
|
-
|
89
|
-
def self::getmeta repo, id
|
90
|
-
Card.new(repo).access(id).getmeta
|
91
|
-
end
|
92
|
-
|
93
|
-
def self::setmeta repo, id, hash
|
94
|
-
Card.new(repo).access(id).setmeta hash
|
95
|
-
end
|
96
|
-
|
97
|
-
def self::delete repo, id
|
98
|
-
Card.new(repo).access(id).delete
|
99
|
-
end
|
100
74
|
|
101
75
|
def getdata
|
102
76
|
data = @content.clone
|
data/lib/gitdb/Contacts.rb
CHANGED
@@ -3,7 +3,7 @@ module Gitdb
|
|
3
3
|
class Contacts
|
4
4
|
|
5
5
|
# 线程锁
|
6
|
-
@@lock =
|
6
|
+
@@lock = Mutex.new
|
7
7
|
|
8
8
|
attr_accessor 'repo'
|
9
9
|
|
@@ -20,20 +20,16 @@ module Gitdb
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def create name
|
23
|
-
# 等待资源可用
|
24
|
-
loop do
|
25
|
-
break unless @@lock
|
26
|
-
end
|
27
|
-
# 锁定资源
|
28
|
-
@@lock = true
|
29
23
|
|
30
|
-
#
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
24
|
+
# 同步信号量
|
25
|
+
@@lock.synchronize {
|
26
|
+
# 生成联系人的唯一编码
|
27
|
+
while exist?(@gid = Gitil::generate_code(4))
|
28
|
+
end
|
29
|
+
# 创建并打开git仓库
|
30
|
+
@repo = Rugged::Repository.init_at "#{STORAGE_PATH}/#{@gid}"
|
31
|
+
}
|
32
|
+
|
37
33
|
# 设置元信息
|
38
34
|
setmeta :name => name, :gid => @gid, :owner => @uid
|
39
35
|
# 读取最后一次提交指向的tree的数据到暂存区
|
data/lib/gitdb/util.rb
CHANGED
@@ -5,7 +5,7 @@ module Gitil
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def self::data_keys_of_card
|
8
|
-
["firstname", "lastname", "mobile", "phone", "email", "birthday", "address", "im"]
|
8
|
+
["firstname", "lastname", "mobile", "phone", "email", "birthday", "address", "im", "note"]
|
9
9
|
end
|
10
10
|
|
11
11
|
def self::meta_keys_of_card
|
data/lib/gitdb/version.rb
CHANGED
data/lib/gitdb.rb
CHANGED