gitdb 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gitdb/Card.rb +15 -2
- data/lib/gitdb/Contacts.rb +20 -10
- data/lib/gitdb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5aa6018d95449efb2183029a5944a5ef0311850a
|
4
|
+
data.tar.gz: 844937233a926d9e64455bf960e9f130dd7dc933
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80a6012d3b3c0c0ac842c5d5bc149332dd085d8d512f332de6543f051ce0cb37dcd9f1b58bf3e53d5771f297937b35e6bcdb58fda8fa68f23f2db85526a4b9f5
|
7
|
+
data.tar.gz: f0bf2535fe3e5a543104fd197a5b606c6cb86d5b1598e8f70edd341c91156421e5258ac818b467f76d36182a56066eeafb8b64692020e70b2b7b7507641cb2ec
|
data/lib/gitdb/Card.rb
CHANGED
@@ -4,6 +4,8 @@ module Gitdb
|
|
4
4
|
|
5
5
|
# 线程锁
|
6
6
|
@@lock = Mutex.new
|
7
|
+
# 记录申请资源的repo, 用于判断是否需要锁
|
8
|
+
@@lock_repo = []
|
7
9
|
|
8
10
|
def initialize repo
|
9
11
|
@repo = repo
|
@@ -40,8 +42,7 @@ module Gitdb
|
|
40
42
|
|
41
43
|
def create uid
|
42
44
|
|
43
|
-
|
44
|
-
@@lock.synchronize {
|
45
|
+
block = Proc.new {
|
45
46
|
# 生成唯一的名片id
|
46
47
|
while exist?(@id = Gitil::generate_code(4))
|
47
48
|
end
|
@@ -52,6 +53,18 @@ module Gitdb
|
|
52
53
|
# 添加到暂存区
|
53
54
|
add_to_stage @id, JSON.pretty_generate(@content)
|
54
55
|
}
|
56
|
+
|
57
|
+
# 如果repo中存在资源申请
|
58
|
+
if @@lock_repo.include? @repo.workdir
|
59
|
+
# 同步信号量
|
60
|
+
@@lock.synchronize &block
|
61
|
+
else
|
62
|
+
# 否则将新的repo加入记录
|
63
|
+
@@lock_repo << @repo.workdir
|
64
|
+
block.call
|
65
|
+
end
|
66
|
+
# 使用结束后清理记录
|
67
|
+
@@lock_repo.delete @repo.workdir
|
55
68
|
|
56
69
|
# 返回Card实例
|
57
70
|
self
|
data/lib/gitdb/Contacts.rb
CHANGED
@@ -49,15 +49,6 @@ module Gitdb
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
# 返回Card实例集合
|
53
|
-
def get_all_cards
|
54
|
-
if @repo.head_unborn?
|
55
|
-
[]
|
56
|
-
else
|
57
|
-
@repo.head.target.tree.collect.each { |o| Card.new(@repo).access o[:name] }
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
52
|
# 返回Card实例
|
62
53
|
def get_card_by_id id
|
63
54
|
if @repo.head_unborn?
|
@@ -67,11 +58,30 @@ module Gitdb
|
|
67
58
|
end
|
68
59
|
end
|
69
60
|
|
61
|
+
# 条件查询
|
62
|
+
# 返回Card实例集合
|
63
|
+
def get_cards &condition
|
64
|
+
if @repo.head_unborn?
|
65
|
+
[]
|
66
|
+
else
|
67
|
+
@repo.head.target.tree.map do |o|
|
68
|
+
yield Card.new(@repo).access o[:name]
|
69
|
+
end.compact
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# 返回Card实例集合
|
74
|
+
def get_all_cards
|
75
|
+
get_cards { |card| card }
|
76
|
+
end
|
77
|
+
|
70
78
|
def getmeta
|
71
79
|
@meta = {
|
72
80
|
:name => @repo.config['repo.name'],
|
73
81
|
:owner => @repo.config['repo.owner'],
|
74
|
-
:gid => @repo.config['repo.gid']
|
82
|
+
:gid => @repo.config['repo.gid'],
|
83
|
+
# 动态获取contacts中card数量
|
84
|
+
:count => @repo.head_unborn? ? 0 : @repo.last_commit.tree.count
|
75
85
|
}
|
76
86
|
end
|
77
87
|
|
data/lib/gitdb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ran
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rugged
|