gkv 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gkv/database.rb +22 -24
- data/lib/gkv/version.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: babd033ffa4d0cb83dbfb9ed1f40b971dda23837
|
4
|
+
data.tar.gz: 87971110ec11daa854c1c56660e6aa60e90309cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7ab8b5d164bb722f6a73641e4e14045f3366cb52082ccdd9fc0db6c1fea2ec188cc813169752cb1834b80b5f7c54720971386a9b80aeb88101db13b691c4964
|
7
|
+
data.tar.gz: e99696505890713c968de364c8e78e731b0ff3dbac5ab3f3f30d4cfe9136b7986498108e02c935a6f5124c9929ca51a155ac6d62fe2d5c6eff4fd61ff8f815ee
|
data/lib/gkv/database.rb
CHANGED
@@ -5,18 +5,14 @@ $ITEMS = {}
|
|
5
5
|
module Gkv
|
6
6
|
class Database
|
7
7
|
include Gkv::DbFunctions
|
8
|
-
attr_accessor :items
|
9
8
|
|
10
9
|
def initialize
|
11
10
|
`git init`
|
11
|
+
@git = Gkv::GitFunctions
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
def load(hash)
|
19
|
-
$ITEMS = YAML.load(Gkv::GitFunctions.cat_file(hash))
|
14
|
+
def []=(key, value)
|
15
|
+
set(key, value)
|
20
16
|
end
|
21
17
|
|
22
18
|
def set(key, value)
|
@@ -24,36 +20,38 @@ module Gkv
|
|
24
20
|
key
|
25
21
|
end
|
26
22
|
|
27
|
-
def []=(key, value)
|
28
|
-
set(key, value)
|
29
|
-
end
|
30
|
-
|
31
|
-
def get(key)
|
32
|
-
if $ITEMS.keys.include? key
|
33
|
-
YAML.load(Gkv::GitFunctions.cat_file($ITEMS[key].last))
|
34
|
-
else
|
35
|
-
raise KeyError
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
23
|
def [](key)
|
40
24
|
get(key)
|
41
25
|
end
|
42
26
|
|
43
27
|
def get_version(version, key)
|
44
|
-
YAML.load(
|
28
|
+
YAML.load(@git.cat_file($ITEMS[key][version.to_i - 1]))
|
45
29
|
end
|
46
30
|
|
47
31
|
def all_versions(key)
|
48
|
-
$ITEMS[key].map { |hash| YAML.load(
|
32
|
+
$ITEMS[key].map { |hash| YAML.load(@git.cat_file(hash)) }
|
33
|
+
end
|
34
|
+
|
35
|
+
def get(key)
|
36
|
+
if $ITEMS.keys.include?(key)
|
37
|
+
YAML.load(@git.cat_file($ITEMS[key].last))
|
38
|
+
else
|
39
|
+
raise KeyError
|
40
|
+
end
|
49
41
|
end
|
50
42
|
|
51
43
|
def all
|
52
44
|
$ITEMS.keys.map { |key|
|
53
|
-
|
54
|
-
value = YAML.load(Gkv::GitFunctions.cat_file(hash))
|
55
|
-
{ "#{key}" => value }
|
45
|
+
{ "#{key}" => YAML.load(@git.cat_file($ITEMS[key].last)) }
|
56
46
|
}
|
57
47
|
end
|
48
|
+
|
49
|
+
def save
|
50
|
+
@git.hash_object(YAML.dump($ITEMS))
|
51
|
+
end
|
52
|
+
|
53
|
+
def load(hash)
|
54
|
+
$ITEMS = YAML.load(@git.cat_file(hash))
|
55
|
+
end
|
58
56
|
end
|
59
57
|
end
|
data/lib/gkv/version.rb
CHANGED