key-db 4.0.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/keydb.rb +1 -22
- metadata +4 -3
data/lib/keydb.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class KeyDB
|
2
2
|
attr_reader :filename, :version
|
3
|
-
$
|
3
|
+
$KEYDB_VERSION = "4.0.1"
|
4
4
|
def initialize filename
|
5
5
|
@filename = filename.split(".")
|
6
6
|
@filename = "#{@filename[0]}.db"
|
@@ -9,27 +9,6 @@ class KeyDB
|
|
9
9
|
@db_file.close
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
13
|
-
def new_key keyname, value
|
14
|
-
if keyname =~ /\/\/\/|\(---\)|-\*\*\*-/
|
15
|
-
raise "Invalid Keyname!"
|
16
|
-
return
|
17
|
-
end
|
18
|
-
File.open(@filename, "r").each_line do |line|
|
19
|
-
if Marshal.load(line).split("///")[0] == keyname
|
20
|
-
raise "Keynames must be unique"
|
21
|
-
return
|
22
|
-
end
|
23
|
-
end
|
24
|
-
if keyname.class != String
|
25
|
-
warn "WARNING: Keyname should be a string"
|
26
|
-
end
|
27
|
-
@db_file = File.open(@filename, "a")
|
28
|
-
@to_write = (Marshal.dump("#{keyname}///#{value}"))
|
29
|
-
@db_file.write(@to_write)
|
30
|
-
@db_file.write("\n")
|
31
|
-
@db_file.close
|
32
|
-
end
|
33
12
|
|
34
13
|
def change_key keyname, value
|
35
14
|
@db_file = File.open(@filename, "a")
|
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: 4.0.
|
4
|
+
version: 4.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,8 @@ date: 2012-05-19 00:00:00.000000000 Z
|
|
13
13
|
dependencies: []
|
14
14
|
description: ! 'A database acessible via keys. Made attributes for all database keys.
|
15
15
|
Database keys now creatable and accessible via: db.foo = ''bar''; db.foo. Cannot
|
16
|
-
change keys through attributes, you must use change_key.
|
16
|
+
change keys through attributes, you must use change_key. Better documentation available
|
17
|
+
at http://keydbdocs.tumblr.com. File to require: ''keydb'''
|
17
18
|
email: slmnwise@gmail.com
|
18
19
|
executables: []
|
19
20
|
extensions: []
|
@@ -21,7 +22,7 @@ extra_rdoc_files: []
|
|
21
22
|
files:
|
22
23
|
- lib/keydb.rb
|
23
24
|
- Diagram.jpg
|
24
|
-
homepage: http://
|
25
|
+
homepage: http://keydbdocs.tumblr.com/
|
25
26
|
licenses: []
|
26
27
|
post_install_message:
|
27
28
|
rdoc_options: []
|