yaml-file-db 0.1.5 → 0.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1dc25fcf9d40ac078b11014d04c8a6ab2bf178f2b7efa72f91aae2405938cb0c
4
- data.tar.gz: 7f1b29cad5a5f17622b5e695be73d1eb7cd20dc1614d364a3ae9c7a5a6a24573
3
+ metadata.gz: e267ac60c172096d2484e3e86854886c4c4dbbeb7c895cae083eea0781d4fb00
4
+ data.tar.gz: 96258128806aea1f96017700203a485f204da736ab0ebcffce36fbfdc2654f57
5
5
  SHA512:
6
- metadata.gz: 5d90892c09e9770d05d627d7ceec0bd3b6fd1a7ff04c35a37e3530ee8c143d2be3686eda81f53d4c2706ded127bf1e14687ef0922cce8f1135e469eabee44983
7
- data.tar.gz: 194504c256053d88b1b75685249e0d08b7c8549b8267df71a67da314c39a60ce3171732253cfd205930bf67db02552b339661c16a401edf2c47aef877ead0608
6
+ metadata.gz: 34099bed1433f9fe540fb4a0f5f1a9a16c63b44f17b2809f6a535438da4968b6e1ae7874278b1628335f391b8fa280af442cd03235b6235764fe01b2501b4c73
7
+ data.tar.gz: ef76c1a1cafe075452fdaaf0d2f0250c0141a05cf81edf028c76bdf54cfb8e22653464df87e15e7430bebcc76367f650f838ff937f6ea3b3b5ac630fe4f950fa
@@ -71,9 +71,9 @@ module YDB
71
71
 
72
72
  table = instance_variable_get var
73
73
  table.each do |_id, row|
74
- block.call(row)
75
- rescue ValidationError => e
76
- @errors << "[#{row.source.split('/')[-3..].join('/')}] #{e}"
74
+ block.call(row).each do |error|
75
+ @errors << "[#{row.source.split('/')[-3..].join('/')}] #{error}"
76
+ end
77
77
  end
78
78
  end
79
79
  end
@@ -15,6 +15,7 @@ module YDB
15
15
  end
16
16
 
17
17
  def build_relationships(db, keywords)
18
+ errors = []
18
19
  iterate_over_columns do |key, value|
19
20
  if keywords.include?(key)
20
21
  if key.pluralize == key
@@ -22,39 +23,41 @@ module YDB
22
23
  table = db.public_send(key.to_sym)
23
24
  value.each do |primary_key|
24
25
  row = table[primary_key]
25
- raise ValidationError, "Invalid primary_key: #{primary_key} isn't part of table #{key}" if row.nil?
26
-
26
+ errors << "Invalid primary_key: #{primary_key} isn't part of table #{key}" if row.nil?
27
27
  rows << row
28
28
  end
29
29
  instance_variable_set("@#{key}", rows)
30
30
  else
31
31
  row = db.public_send(key.pluralize.to_sym)[value]
32
- raise ValidationError, "Invalid primary_key: #{value} isn't part of table #{key.pluralize}" if row.nil?
33
-
32
+ errors << "Invalid primary_key: #{value} isn't part of table #{key.pluralize}" if row.nil?
34
33
  instance_variable_set("@#{key}", row)
35
34
  end
36
35
  end
37
36
  end
37
+ errors
38
38
  end
39
39
 
40
40
  def check_relationships(_db, keywords)
41
+ errors = []
41
42
  iterate_over_columns do |key, value|
42
43
  if keywords.include?(key)
43
- # move row into array to make it iterable
44
+ next if value.nil?
45
+
44
46
  value = [value] if value.is_a?(YDB::Row)
45
47
  value.each do |row|
46
48
  if row.respond_to?(self.class.to_s.downcase.to_sym)
47
49
  unless row.public_send(self.class.to_s.downcase.to_sym) == self
48
- raise ValidationError, "Inconsistent relationship: #{row.id} doesn't link back to #{id}"
50
+ errors << "Inconsistent relationship: #{row.id} doesn't link back to #{id}"
49
51
  end
50
52
  elsif row.respond_to?(self.class.to_s.downcase.pluralize.to_sym)
51
53
  unless row.public_send(self.class.to_s.downcase.pluralize.to_sym).include?(self)
52
- raise ValidationError, "Inconsistent relationship: #{row.id} doesn't link back to #{id}"
54
+ errors << "Inconsistent relationship: #{row.id} doesn't link back to #{id}"
53
55
  end
54
56
  end
55
57
  end
56
58
  end
57
59
  end
60
+ errors
58
61
  end
59
62
 
60
63
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaml-file-db
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis-Philippe Gauthier