key-db 1.1.0 → 1.1.1

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.
Files changed (2) hide show
  1. data/lib/keydb.rb +9 -3
  2. metadata +4 -4
data/lib/keydb.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  class KeyDB
2
+
2
3
  def initialize filename
3
4
  @filename = filename.split(".")
4
5
  @filename = "#{@filename[0]}.db"
@@ -7,6 +8,7 @@ class KeyDB
7
8
  @db_file.close
8
9
  end
9
10
  end
11
+
10
12
  def new_key keyname, value
11
13
  @db_file = File.open(@filename, "a")
12
14
  @to_write = (Marshal.dump("#{keyname}/#{value}"))
@@ -14,6 +16,7 @@ class KeyDB
14
16
  @db_file.write("\n")
15
17
  @db_file.close
16
18
  end
19
+
17
20
  def get_key keyname
18
21
  File.open(@filename, "r").each_line do |line|
19
22
  line = Marshal.load(line)
@@ -23,16 +26,19 @@ class KeyDB
23
26
  end
24
27
  end
25
28
  end
29
+
26
30
  def access type
27
31
  File.open(@filename).each_line do |line|
28
32
  line = Marshal.load(line)
29
33
  @keys_and_vals = line.split('/')
30
34
  if type == "keys"
31
- index = 0
35
+ puts @keys_and_vals[0]
32
36
  elsif type == "vals"
33
- index = 1
37
+ puts @keys_and_vals[1]
38
+ else
39
+ raise "Invalid Argument"
34
40
  end
35
- puts @keys_and_vals[index]
36
41
  end
37
42
  end
43
+
38
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: key-db
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,10 +9,10 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-10 00:00:00.000000000 Z
12
+ date: 2012-05-11 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description: A database acessible via keys, bugs fixed, marshaling included. Renamed
15
- HashKeyDB to KeyDB
14
+ description: ! 'A database acessible via keys, bugs fixed. Error Handling included.
15
+ File to require: ''keydb'''
16
16
  email: slmnwise@gmail.com
17
17
  executables: []
18
18
  extensions: []