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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d9d15f38f399a55846936dd316f7c6d62338efe
4
- data.tar.gz: bf35d222841772c66cafa0e7d02994e3389c229e
3
+ metadata.gz: babd033ffa4d0cb83dbfb9ed1f40b971dda23837
4
+ data.tar.gz: 87971110ec11daa854c1c56660e6aa60e90309cb
5
5
  SHA512:
6
- metadata.gz: 178b8e66c48d775fed1f20b5c17a90dda51d3daf540a9229e43435c77a6441f4774a42e98eda778d57bd5519cccf09c06dc96f918ed731c4fdc7cbc126b264c8
7
- data.tar.gz: 90aad818884a09d5d142178cca7da4fd0f1cb2b294f07dca3288a4e7ee8284c853829a29bfb27a91f7d554ae90e6aa06cc4bd23474fa4a98a6fae99e03f6b475
6
+ metadata.gz: f7ab8b5d164bb722f6a73641e4e14045f3366cb52082ccdd9fc0db6c1fea2ec188cc813169752cb1834b80b5f7c54720971386a9b80aeb88101db13b691c4964
7
+ data.tar.gz: e99696505890713c968de364c8e78e731b0ff3dbac5ab3f3f30d4cfe9136b7986498108e02c935a6f5124c9929ca51a155ac6d62fe2d5c6eff4fd61ff8f815ee
@@ -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 save
15
- Gkv::GitFunctions.hash_object(YAML.dump($ITEMS))
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(Gkv::GitFunctions.cat_file($ITEMS[key][version.to_i - 1]))
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(Gkv::GitFunctions.cat_file(hash)) }
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
- hash = $ITEMS[key].last
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
@@ -1,3 +1,3 @@
1
1
  module Gkv
2
- VERSION = '0.2.6'
2
+ VERSION = '0.2.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gkv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - '='