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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b759526ad3c7265b6ac63d0c3b9eb71ce5daa8e0
4
- data.tar.gz: 50bec8e6486e92c06b570236510c5637683c2b64
3
+ metadata.gz: f7a1bc21909ffaeca6f702432301c0d394401eba
4
+ data.tar.gz: ae4fd5a9480cc5d4be7e3907fbf289fcfe733242
5
5
  SHA512:
6
- metadata.gz: 4a368ef5bd7a21994a7ba199015eaa943a9fdd0098e3218781839e129d8c87b673407bbe0ade5719912494b0d1e80f84f3189d17a3727ca0646e0c144f94c8ee
7
- data.tar.gz: dee8285fb119dc87f3c5d22c7767976cfd91de9e2ab26fa7af87998c3b9385894a915b87a219c2a7652cee1d825767c80e47a409ab0f90ffc12fe4b538a518a1
6
+ metadata.gz: 0fe76feada56a5c5fd80ff8eca7782620cfd42c3a9bf7c5635abeaaeec57c3d2b88575fd1174cf1a2625f71b0f65e6a56d171ca9b1bdba60a2395f0cbb49d047
7
+ data.tar.gz: 35bcf802052c086c85ff8ae009009115b9675c88437d22294113bbcf566e1fab9d25b7d8146b0d0220739158b62fa58f246113e4efbdf0e0e86706d2371370d0
data/.gitignore CHANGED
@@ -11,4 +11,6 @@
11
11
  *.so
12
12
  *.o
13
13
  *.a
14
- mkmf.log
14
+ storage/
15
+ .*
16
+ *.log
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Gitdb
2
2
 
3
- TODO: Write a gem description
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
- TODO: Write usage instructions here
24
+ #### Module: `Gitdb`
24
25
 
25
- ## Contributing
26
+ + constant: `Gitdb::STORAGE_PATH`
27
+ + class method: `setup_storage`
26
28
 
27
- 1. Fork it ( https://github.com/[my-github-username]/gitdb/fork )
28
- 2. Create your feature branch (`git checkout -b my-new-feature`)
29
- 3. Commit your changes (`git commit -am 'Add some feature'`)
30
- 4. Push to the branch (`git push origin my-new-feature`)
31
- 5. Create a new Pull Request
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
- write_to_stage @id, JSON.pretty_generate(@content)
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, 然后才能继续调用write_to_stage
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 write_to_stage id, content
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
@@ -1,3 +1,3 @@
1
1
  module Gitdb
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/gitdb.rb CHANGED
@@ -9,7 +9,7 @@ require_relative 'gitdb/Contacts'
9
9
  module Gitdb
10
10
 
11
11
  # 主存储目录
12
- STORAGE_PATH = File::expand_path '../../../storage', __FILE__
12
+ STORAGE_PATH = "#{Dir::pwd}/storage"
13
13
 
14
14
  # 检查并创建主存储目录
15
15
  def self::setup_storage
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ran