database_consistency 2.0.3 → 2.0.5

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: 10a47440f23b099f99610cd51a5150d741c36f439db1b41ed013c7e471d055e2
4
- data.tar.gz: d41e1338822d6bde0dda339d1be9f1e719559c493d6ed93df2fe430457155ef9
3
+ metadata.gz: 2380b5d06cadf5a7b6d7f7eb68c7629e6f0da93ecd3d56f1f82799c53d85f6c4
4
+ data.tar.gz: 6cd306465b2d4a4aca367e3d5c8679093668fc48777b58e767c1da88f4c9363f
5
5
  SHA512:
6
- metadata.gz: 48cffa667822acc96791b45f2c5821cd3920ed217d451340361d8184dac927843755940443e2e4506358847736687aab5d4adbe1c68e5f3db08da35d9b9a1ff9
7
- data.tar.gz: bfe3e7df7e47c4988aeae5fe9c2157786c221047fec5a0f9f435457020f65d99ebb2722c94ddce4204ed84a49ffdab8849fc85ab5e282d39722bcf68ddd4e9cd
6
+ metadata.gz: 0caf35c6c8f9f65a5fdfa215ae500890142b780ef7052a78bc1ecff31176293e034432ac3f75db01f757c8ef5260a719869d029611324d89253b7b3b608335eb
7
+ data.tar.gz: 3e8265c255738814f0b5f5ff044723e7052a5d920f72ede5450add483bc6ebb68c8eea45b4470ee35c4edc04a7736409179c5dea296f28b55cc2ed082a5ace3d
@@ -6,6 +6,10 @@ module DatabaseConsistency
6
6
  class AssociationChecker < BaseChecker
7
7
  attr_reader :model, :association
8
8
 
9
+ def self.processor
10
+ Processors::AssociationsProcessor
11
+ end
12
+
9
13
  def initialize(model, association)
10
14
  super()
11
15
  @model = model
@@ -16,8 +16,7 @@ module DatabaseConsistency
16
16
 
17
17
  return if subclass.superclass.name == 'DatabaseConsistency::Checkers::BaseChecker'
18
18
 
19
- processor_prefix = subclass.superclass.name.demodulize.delete_suffix('Checker').pluralize
20
- processor = "DatabaseConsistency::Processors::#{processor_prefix}Processor".constantize
19
+ processor = subclass.processor
21
20
  processor.checkers << subclass
22
21
  end
23
22
 
@@ -6,6 +6,10 @@ module DatabaseConsistency
6
6
  class ColumnChecker < BaseChecker
7
7
  attr_reader :model, :column
8
8
 
9
+ def self.processor
10
+ Processors::ColumnsProcessor
11
+ end
12
+
9
13
  def initialize(model, column)
10
14
  super()
11
15
  @model = model
@@ -38,7 +38,11 @@ module DatabaseConsistency
38
38
  @enum_column_values ||=
39
39
  if model.connection.enum_types.is_a?(Array)
40
40
  _, values = model.connection.enum_types.find { |(enum, _)| enum == column.sql_type }
41
- values.split(',').map(&:strip)
41
+ case values
42
+ when Array then values
43
+ else
44
+ values.split(',').map(&:strip)
45
+ end
42
46
  else
43
47
  # active_record-postgres_enum gem
44
48
  model.connection.enum_types[column.sql_type.to_sym]
@@ -6,6 +6,10 @@ module DatabaseConsistency
6
6
  class EnumChecker < BaseChecker
7
7
  attr_reader :model, :enum
8
8
 
9
+ def self.processor
10
+ Processors::EnumsProcessor
11
+ end
12
+
9
13
  def initialize(model, enum)
10
14
  super()
11
15
  @model = model
@@ -6,6 +6,10 @@ module DatabaseConsistency
6
6
  class IndexChecker < BaseChecker
7
7
  attr_reader :model, :index
8
8
 
9
+ def self.processor
10
+ Processors::IndexesProcessor
11
+ end
12
+
9
13
  def initialize(model, index)
10
14
  super()
11
15
  @model = model
@@ -6,6 +6,10 @@ module DatabaseConsistency
6
6
  class ModelChecker < BaseChecker
7
7
  attr_reader :model
8
8
 
9
+ def self.processor
10
+ Processors::ModelsProcessor
11
+ end
12
+
9
13
  def initialize(model)
10
14
  super()
11
15
  @model = model
@@ -6,6 +6,10 @@ module DatabaseConsistency
6
6
  class ValidatorChecker < BaseChecker
7
7
  attr_reader :model, :attribute, :validator
8
8
 
9
+ def self.processor
10
+ Processors::ValidatorsProcessor
11
+ end
12
+
9
13
  def initialize(model, attribute, validator)
10
14
  super()
11
15
  @model = model
@@ -6,6 +6,10 @@ module DatabaseConsistency
6
6
  class ValidatorsFractionChecker < BaseChecker
7
7
  attr_reader :model, :attribute, :validators
8
8
 
9
+ def self.processor
10
+ Processors::ValidatorsFractionsProcessor
11
+ end
12
+
9
13
  def initialize(model, attribute, validators)
10
14
  super()
11
15
  @model = model
@@ -8,15 +8,16 @@ module DatabaseConsistency
8
8
  DEFAULT_PATH = '.database_consistency.yml'
9
9
 
10
10
  def initialize(file_paths = DEFAULT_PATH)
11
- @configuration = existing_configurations(file_paths).then do |existing_paths|
12
- if existing_paths.any?
13
- puts "Loaded configurations: #{existing_paths.join(', ')}"
14
- else
15
- puts 'No configurations were provided'
16
- end
17
- extract_configurations(existing_paths)
11
+ existing_paths = existing_configurations(file_paths)
12
+
13
+ if existing_paths.any?
14
+ puts "Loaded configurations: #{existing_paths.join(', ')}"
15
+ else
16
+ puts 'No configurations were provided'
18
17
  end
19
18
 
19
+ @configuration = extract_configurations(existing_paths)
20
+
20
21
  load_custom_checkers
21
22
  end
22
23
 
@@ -30,7 +30,6 @@ module DatabaseConsistency
30
30
  store.each do |key, value|
31
31
  destination.puts("#{key}: #{value}")
32
32
  end
33
- clear!
34
33
  end
35
34
 
36
35
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DatabaseConsistency
4
- VERSION = '2.0.3'
4
+ VERSION = '2.0.5'
5
5
  end
@@ -1,11 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'active_record'
4
- require 'active_support/inflector'
5
-
6
- ActiveSupport::Inflector.inflections do |inflect|
7
- inflect.irregular 'index', 'indexes'
8
- end
9
4
 
10
5
  require 'database_consistency/version'
11
6
  require 'database_consistency/helper'
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: 2.0.3
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeniy Demin
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-01 00:00:00.000000000 Z
11
+ date: 2025-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -136,7 +136,7 @@ dependencies:
136
136
  - - ">"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '1.3'
139
- description:
139
+ description:
140
140
  email:
141
141
  - lawliet.djez@gmail.com
142
142
  executables:
@@ -273,10 +273,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
273
273
  - !ruby/object:Gem::Version
274
274
  version: '0'
275
275
  requirements: []
276
- rubygems_version: 3.2.33
277
- signing_key:
276
+ rubygems_version: 3.4.1
277
+ signing_key:
278
278
  specification_version: 4
279
279
  summary: Provide an easy way to check the consistency of the database constraints
280
280
  with the application validations.
281
281
  test_files: []
282
- ...