key-db 2.2.1 → 2.3.0
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.
- data/lib/keydb.rb +10 -10
- metadata +3 -3
data/lib/keydb.rb
CHANGED
@@ -11,12 +11,12 @@ class KeyDB
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def new_key keyname, value
|
14
|
-
if keyname =~
|
14
|
+
if keyname =~ /\/\/\/|\(---\)/
|
15
15
|
raise "Invalid Keyname!"
|
16
16
|
return
|
17
17
|
end
|
18
18
|
File.open(@filename, "r").each_line do |line|
|
19
|
-
if Marshal.load(line).split("
|
19
|
+
if Marshal.load(line).split("///")[0] == keyname
|
20
20
|
raise "Keynames must be unique"
|
21
21
|
return
|
22
22
|
end
|
@@ -25,7 +25,7 @@ class KeyDB
|
|
25
25
|
warn "WARNING: Keyname should be a string"
|
26
26
|
end
|
27
27
|
@db_file = File.open(@filename, "a")
|
28
|
-
@to_write = (Marshal.dump("#{keyname}
|
28
|
+
@to_write = (Marshal.dump("#{keyname}///#{value}"))
|
29
29
|
@db_file.write(@to_write)
|
30
30
|
@db_file.write("\n")
|
31
31
|
@db_file.close
|
@@ -42,8 +42,8 @@ class KeyDB
|
|
42
42
|
end
|
43
43
|
File.open(@filename, "r").each_line do |line|
|
44
44
|
line = Marshal.load(line)
|
45
|
-
if line.split("
|
46
|
-
return line.split("
|
45
|
+
if line.split("///")[0] == keyname
|
46
|
+
return line.split("///")[1]
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -64,21 +64,21 @@ class KeyDB
|
|
64
64
|
end
|
65
65
|
File.open(@filename).each_line do |line|
|
66
66
|
line = Marshal.load(line)
|
67
|
-
@keys_and_vals = line.split('
|
67
|
+
@keys_and_vals = line.split('///')
|
68
68
|
if type == "keys"
|
69
|
-
if line.split("(---)").length == 2 or to_ignore.include? line.split("
|
69
|
+
if line.split("(---)").length == 2 or to_ignore.include? line.split("///")[0]
|
70
70
|
print
|
71
71
|
else
|
72
72
|
puts @keys_and_vals[0]
|
73
73
|
end
|
74
74
|
elsif type == "vals"
|
75
|
-
if line.split("(---)").length == 2 or to_ignore.include? line.split("
|
75
|
+
if line.split("(---)").length == 2 or to_ignore.include? line.split("///")[0]
|
76
76
|
print
|
77
77
|
else
|
78
78
|
puts @keys_and_vals[1]
|
79
79
|
end
|
80
80
|
elsif type == "all"
|
81
|
-
if line.split("(---)").length == 2 or to_ignore.include? line.split("
|
81
|
+
if line.split("(---)").length == 2 or to_ignore.include? line.split("///")[0]
|
82
82
|
print
|
83
83
|
else
|
84
84
|
puts line
|
@@ -93,7 +93,7 @@ class KeyDB
|
|
93
93
|
system("rm #{@filename}")
|
94
94
|
end
|
95
95
|
|
96
|
-
def
|
96
|
+
def wipe_db
|
97
97
|
delete_db
|
98
98
|
File.new(@filename, "w")
|
99
99
|
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: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,8 +11,8 @@ bindir: bin
|
|
11
11
|
cert_chain: []
|
12
12
|
date: 2012-05-13 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
|
-
description: ! 'A database acessible via keys. Added delete_key method and
|
15
|
-
method.
|
14
|
+
description: ! 'A database acessible via keys. Added delete_key method and wipe_db
|
15
|
+
method. Changed key validation slightly. File to require: ''keydb'''
|
16
16
|
email: slmnwise@gmail.com
|
17
17
|
executables: []
|
18
18
|
extensions: []
|