gitdb 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/README.md +38 -8
- data/lib/gitdb/Card.rb +3 -3
- data/lib/gitdb/version.rb +1 -1
- data/lib/gitdb.rb +1 -1
- 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: f7a1bc21909ffaeca6f702432301c0d394401eba
|
4
|
+
data.tar.gz: ae4fd5a9480cc5d4be7e3907fbf289fcfe733242
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fe76feada56a5c5fd80ff8eca7782620cfd42c3a9bf7c5635abeaaeec57c3d2b88575fd1174cf1a2625f71b0f65e6a56d171ca9b1bdba60a2395f0cbb49d047
|
7
|
+
data.tar.gz: 35bcf802052c086c85ff8ae009009115b9675c88437d22294113bbcf566e1fab9d25b7d8146b0d0220739158b62fa58f246113e4efbdf0e0e86706d2371370d0
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Gitdb
|
2
2
|
|
3
|
-
|
3
|
+
**Git-Contacts** backend data engine
|
4
|
+
a simple data storage based on git, designed for Git-Contacts
|
4
5
|
|
5
6
|
## Installation
|
6
7
|
|
@@ -20,12 +21,41 @@ Or install it yourself as:
|
|
20
21
|
|
21
22
|
## Usage
|
22
23
|
|
23
|
-
|
24
|
+
#### Module: `Gitdb`
|
24
25
|
|
25
|
-
|
26
|
+
+ constant: `Gitdb::STORAGE_PATH`
|
27
|
+
+ class method: `setup_storage`
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
#### Class: `Gitdb::Contacts`
|
30
|
+
|
31
|
+
+ class method: `exist?(gid)`
|
32
|
+
|
33
|
+
##### instance: `Gitdb::Contacts.new(uid)`
|
34
|
+
|
35
|
+
+ property: `repo`
|
36
|
+
+ method: `exist?(gid)`
|
37
|
+
+ method: `create(gid)`
|
38
|
+
+ method: `access(gid)`
|
39
|
+
+ method: `getmeta`
|
40
|
+
+ method: `setmeta(Hash)`
|
41
|
+
+ method: `get_all_cards`
|
42
|
+
+ method: `get_card_by_id(id)`
|
43
|
+
+ method: `read_change_history`
|
44
|
+
+ method: `revert_to(sha, authorhash, message)`
|
45
|
+
+ method: `make_a_commit(optionhash)`
|
46
|
+
|
47
|
+
#### Class: `Gitdb::Card`
|
48
|
+
|
49
|
+
+ class method: `exist?(repo, id)`
|
50
|
+
|
51
|
+
##### instance: `Gitdb::Card.new(repo)`
|
52
|
+
|
53
|
+
+ method: `create(uid)`
|
54
|
+
+ method: `access(id)`
|
55
|
+
+ method: `format_card(id, uid)`
|
56
|
+
+ method: `getdata`
|
57
|
+
+ method: `setdata(Hash)`
|
58
|
+
+ method: `getmeta`
|
59
|
+
+ method: `setmeta(Hash)`
|
60
|
+
+ method: `delete`
|
61
|
+
+ method: `add_to_stage(id, content)`
|
data/lib/gitdb/Card.rb
CHANGED
@@ -93,7 +93,7 @@ module Gitdb
|
|
93
93
|
@content[sym_key] = hash[sym_key]
|
94
94
|
end
|
95
95
|
# 每次对数据的修改会触发一次"写入暂存区"
|
96
|
-
|
96
|
+
add_to_stage @id, JSON.pretty_generate(@content)
|
97
97
|
end
|
98
98
|
|
99
99
|
def getmeta
|
@@ -104,13 +104,13 @@ module Gitdb
|
|
104
104
|
@content[:meta] = hash
|
105
105
|
end
|
106
106
|
|
107
|
-
# Notice: 调用delete之后需要先commit, 然后才能继续调用
|
107
|
+
# Notice: 调用delete之后需要先commit, 然后才能继续调用add_to_stage
|
108
108
|
def delete
|
109
109
|
@repo.index.read_tree @repo.head.target.tree unless @repo.branches.count == 0
|
110
110
|
@repo.index.find { |blob| @repo.index.remove blob[:path] if blob[:path] == @id }
|
111
111
|
end
|
112
112
|
|
113
|
-
def
|
113
|
+
def add_to_stage id, content
|
114
114
|
oid = @repo.write content, :blob
|
115
115
|
@repo.index.read_tree @repo.head.target.tree unless @repo.branches.count == 0
|
116
116
|
@repo.index.add :path => id, :oid => oid, :mode => 0100644
|
data/lib/gitdb/version.rb
CHANGED
data/lib/gitdb.rb
CHANGED