jsondb 0.1.1 → 0.1.3
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.
- checksums.yaml +4 -4
- data/lib/jsondb/db.rb +2 -2
- data/lib/jsondb/field.rb +4 -4
- data/lib/jsondb/table.rb +2 -2
- data/lib/jsondb/validations.rb +2 -0
- 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: 61a6198adacb39d4cf5d56690de2272b6a27bb72
|
|
4
|
+
data.tar.gz: 9e86447e3b4bee5e052f392600bfcd221b3106ca
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8cc00e9259a6cb6c398441bc48246d954252d61631dec141d4c75ad358ab6e78167632879cc867f5c8004b2dc4b9638a76223bec7d94c59c0af9402ad739be57
|
|
7
|
+
data.tar.gz: 3e655c3ee184706746e5cdec041db7374532276a82d72a8ea97115ef0ee885c85c53026b02efac40d0e519609c4821b7c07813032246c8c5c017070029ee9f11
|
data/lib/jsondb/db.rb
CHANGED
|
@@ -62,7 +62,7 @@ module JSONdb
|
|
|
62
62
|
tables_in_file = @file.contents['tables']
|
|
63
63
|
|
|
64
64
|
tables_in_file.each do |table_name, values|
|
|
65
|
-
JSONdb.tables[table_name] = JSONdb::Table.new(
|
|
65
|
+
JSONdb.tables[table_name] = JSONdb::Table.new(table_name, false)
|
|
66
66
|
JSONdb.tables[table_name].created_at = values['created_at']
|
|
67
67
|
JSONdb.tables[table_name].updated_at = values['updated_at']
|
|
68
68
|
JSONdb.tables[table_name].last_id = values['last_id']
|
|
@@ -72,7 +72,7 @@ module JSONdb
|
|
|
72
72
|
fields_in_file.each do |field_name, field_values|
|
|
73
73
|
JSONdb.fields[table_name][field_name] = Field.new(field_name)
|
|
74
74
|
JSONdb.fields[table_name][field_name].type = field_values['type']
|
|
75
|
-
JSONdb.fields[table_name][field_name].
|
|
75
|
+
JSONdb.fields[table_name][field_name].nullable = field_values['nullable']
|
|
76
76
|
JSONdb.fields[table_name][field_name].default = field_values['default']
|
|
77
77
|
end
|
|
78
78
|
end
|
data/lib/jsondb/field.rb
CHANGED
|
@@ -6,7 +6,7 @@ module JSONdb
|
|
|
6
6
|
include JSONdb::Validations::Types
|
|
7
7
|
include JSONdb::Logger
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
#attr_accessor :type, :nullable, :default
|
|
10
10
|
|
|
11
11
|
def initialize(name)
|
|
12
12
|
@name = name if allowed_name?(name)
|
|
@@ -14,14 +14,14 @@ module JSONdb
|
|
|
14
14
|
# override common setters
|
|
15
15
|
self.type = "String"
|
|
16
16
|
self.nullable = true
|
|
17
|
-
self.default =
|
|
17
|
+
self.default = nil
|
|
18
18
|
|
|
19
19
|
# set_defaults
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def type=(_class)
|
|
23
23
|
if allowed_type?(_class)
|
|
24
|
-
@type = _class
|
|
24
|
+
@type = _class
|
|
25
25
|
return true
|
|
26
26
|
else
|
|
27
27
|
log("'#{_class}' not allowed as field type", :error)
|
|
@@ -73,7 +73,7 @@ module JSONdb
|
|
|
73
73
|
|
|
74
74
|
def set_defaults
|
|
75
75
|
@nullable = true
|
|
76
|
-
@default =
|
|
76
|
+
@default = nil
|
|
77
77
|
@type = "String"
|
|
78
78
|
end
|
|
79
79
|
|
data/lib/jsondb/table.rb
CHANGED
|
@@ -7,8 +7,8 @@ module JSONdb
|
|
|
7
7
|
include JSONdb::Fields
|
|
8
8
|
include JSONdb::Records
|
|
9
9
|
|
|
10
|
-
attr_reader
|
|
11
|
-
attr_accessor :timestamp
|
|
10
|
+
attr_reader :persisted
|
|
11
|
+
attr_accessor :timestamp, :created_at, :updated_at, :last_id
|
|
12
12
|
|
|
13
13
|
def initialize(name, new_table = true)
|
|
14
14
|
@name = name
|
data/lib/jsondb/validations.rb
CHANGED