database_consistency 1.7.10 → 1.7.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/database_consistency/configuration.rb +16 -2
- data/lib/database_consistency/helper.rb +4 -0
- data/lib/database_consistency/processors/associations_processor.rb +3 -2
- data/lib/database_consistency/processors/columns_processor.rb +3 -2
- data/lib/database_consistency/processors/enums_processor.rb +3 -2
- data/lib/database_consistency/processors/indexes_processor.rb +2 -1
- data/lib/database_consistency/processors/validators_fractions_processor.rb +3 -2
- data/lib/database_consistency/processors/validators_processor.rb +3 -2
- data/lib/database_consistency/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8560e4cc5588b8182f8d5258703894839190a758abf57e35e2abe81a630848fc
|
4
|
+
data.tar.gz: 26b96205cd47d48f9a557d6986ef2d2f0eef940f1407ed430760f6201c91cca5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfb1870b761338b23481926ec64cea7a814b7a174937d5035ca6a71ef63f7cfd332db6ab243f15ff5e9990a6445522b5565d2103b0c45eeb147f22eddbc48d7f
|
7
|
+
data.tar.gz: feec3a2004be04efe8ab1329a79b4b4395ffa3feec5c7798ad04b8218b7365b917a89a80681409d9a1827a5620105a7295ff6b67863828dd85b555c1dc8e7e7f
|
@@ -9,7 +9,11 @@ module DatabaseConsistency
|
|
9
9
|
|
10
10
|
def initialize(file_paths = DEFAULT_PATH)
|
11
11
|
@configuration = existing_configurations(file_paths).then do |existing_paths|
|
12
|
-
|
12
|
+
if existing_paths.any?
|
13
|
+
puts "Loaded configurations: #{existing_paths.join(', ')}"
|
14
|
+
else
|
15
|
+
puts 'No configurations were provided'
|
16
|
+
end
|
13
17
|
extract_configurations(existing_paths)
|
14
18
|
end
|
15
19
|
end
|
@@ -33,7 +37,7 @@ module DatabaseConsistency
|
|
33
37
|
value = global_enabling
|
34
38
|
|
35
39
|
path.each do |key|
|
36
|
-
current =
|
40
|
+
current = find(key.to_s, current)
|
37
41
|
return value unless current.is_a?(Hash)
|
38
42
|
|
39
43
|
next if current['enabled'].nil?
|
@@ -48,6 +52,16 @@ module DatabaseConsistency
|
|
48
52
|
|
49
53
|
attr_reader :configuration
|
50
54
|
|
55
|
+
def find(key, configuration)
|
56
|
+
return configuration[key] if configuration.key?(key)
|
57
|
+
|
58
|
+
configuration.find { |(k, _)| k.include?('*') && key.match?(generate_regexp(k)) }&.last
|
59
|
+
end
|
60
|
+
|
61
|
+
def generate_regexp(str)
|
62
|
+
/\A#{str.gsub('*', '.*')}\z/
|
63
|
+
end
|
64
|
+
|
51
65
|
def existing_configurations(paths)
|
52
66
|
Array(paths).select do |filepath|
|
53
67
|
filepath && File.exist?(filepath)
|
@@ -13,9 +13,10 @@ module DatabaseConsistency
|
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
-
def check
|
16
|
+
def check # rubocop:disable Metrics/AbcSize
|
17
17
|
Helper.models.flat_map do |model|
|
18
|
-
next unless configuration.enabled?(model
|
18
|
+
next unless configuration.enabled?('DatabaseConsistencyDatabases', Helper.database_name(model)) &&
|
19
|
+
configuration.enabled?(model.name.to_s)
|
19
20
|
|
20
21
|
Helper.first_level_associations(model).flat_map do |association|
|
21
22
|
enabled_checkers.flat_map do |checker_class|
|
@@ -14,9 +14,10 @@ module DatabaseConsistency
|
|
14
14
|
|
15
15
|
private
|
16
16
|
|
17
|
-
def check
|
17
|
+
def check # rubocop:disable Metrics/AbcSize
|
18
18
|
Helper.parent_models.flat_map do |model|
|
19
|
-
next unless configuration.enabled?(model
|
19
|
+
next unless configuration.enabled?('DatabaseConsistencyDatabases', Helper.database_name(model)) &&
|
20
|
+
configuration.enabled?(model.name.to_s)
|
20
21
|
|
21
22
|
model.columns.flat_map do |column|
|
22
23
|
enabled_checkers.flat_map do |checker_class|
|
@@ -10,9 +10,10 @@ module DatabaseConsistency
|
|
10
10
|
|
11
11
|
private
|
12
12
|
|
13
|
-
def check
|
13
|
+
def check # rubocop:disable Metrics/AbcSize
|
14
14
|
Helper.models.flat_map do |model|
|
15
|
-
next unless configuration.enabled?(model
|
15
|
+
next unless configuration.enabled?('DatabaseConsistencyDatabases', Helper.database_name(model)) &&
|
16
|
+
configuration.enabled?(model.name.to_s)
|
16
17
|
|
17
18
|
model.defined_enums.keys.flat_map do |enum|
|
18
19
|
enabled_checkers.flat_map do |checker_class|
|
@@ -14,7 +14,8 @@ module DatabaseConsistency
|
|
14
14
|
|
15
15
|
def check # rubocop:disable Metrics/AbcSize
|
16
16
|
Helper.parent_models.flat_map do |model|
|
17
|
-
next unless configuration.enabled?(model
|
17
|
+
next unless configuration.enabled?('DatabaseConsistencyDatabases', Helper.database_name(model)) &&
|
18
|
+
configuration.enabled?(model.name.to_s)
|
18
19
|
|
19
20
|
indexes = model.connection.indexes(model.table_name)
|
20
21
|
|
@@ -11,9 +11,10 @@ module DatabaseConsistency
|
|
11
11
|
private
|
12
12
|
|
13
13
|
# @return [Array<Hash>]
|
14
|
-
def check
|
14
|
+
def check # rubocop:disable Metrics/AbcSize
|
15
15
|
Helper.parent_models.flat_map do |model|
|
16
|
-
next unless configuration.enabled?(model
|
16
|
+
next unless configuration.enabled?('DatabaseConsistencyDatabases', Helper.database_name(model)) &&
|
17
|
+
configuration.enabled?(model.name.to_s)
|
17
18
|
|
18
19
|
model._validators.flat_map do |attribute, validators|
|
19
20
|
next unless attribute
|
@@ -12,9 +12,10 @@ module DatabaseConsistency
|
|
12
12
|
private
|
13
13
|
|
14
14
|
# @return [Array<Hash>]
|
15
|
-
def check # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
15
|
+
def check # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity
|
16
16
|
Helper.parent_models.flat_map do |model|
|
17
|
-
next unless configuration.enabled?(model
|
17
|
+
next unless configuration.enabled?('DatabaseConsistencyDatabases', Helper.database_name(model)) &&
|
18
|
+
configuration.enabled?(model.name.to_s)
|
18
19
|
|
19
20
|
model.validators.flat_map do |validator|
|
20
21
|
next unless validator.respond_to?(:attributes)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: database_consistency
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evgeniy Demin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -264,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
264
264
|
- !ruby/object:Gem::Version
|
265
265
|
version: '0'
|
266
266
|
requirements: []
|
267
|
-
rubygems_version: 3.
|
267
|
+
rubygems_version: 3.1.6
|
268
268
|
signing_key:
|
269
269
|
specification_version: 4
|
270
270
|
summary: Provide an easy way to check the consistency of the database constraints
|