database_consistency 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac7b129ad6e59c2caaa2d9d09cf4a41ac10f99ed13800c2a9e87dfd015202ae5
4
- data.tar.gz: 5015865dbf2785bce72ba9722c0b1cfd6f83235537686c1ac636a2cb2fe87a34
3
+ metadata.gz: f35fd47d191dad146fc189990674ed806ea0a024011b41ef83e9fbe61a031ecc
4
+ data.tar.gz: 46b44a37b9e4d4b13ceb17b16929ae8e7c8a11a360c6cb5adc7385859600ae21
5
5
  SHA512:
6
- metadata.gz: c6d3f99b6d187c74f9c9be5b91f8395bf74a161466914271987e316e99424b914dde2f46e434faaa05939954c62f69345039fe6db0bd58b1fb47225bb0e6ac66
7
- data.tar.gz: fb98a2c911f021203a97482e3e7df30e71c809a187f58beeee4f8b5759533d8557ad1e99ad30950382e36c0f53740be837cbff96166dbff8feb7819e80729aa9
6
+ metadata.gz: 7f2eab4d81e85c90c88368d46122cf83b0a823af849fa5ebf68e419173e43cbc0dc4420bc219e745263b78c1e304d361fa44522f6bdad9913057979ec393822a
7
+ data.tar.gz: 260fbd40013cbab95bce38847badad9a1f3cde38e1afd69d58dba7ce1e7f03dee4bb21dc75249401dbf27f966efbce28a41a2307f65aac312f4635225846054d
@@ -23,5 +23,5 @@ $LOAD_PATH.unshift(File.expand_path('lib', __dir__))
23
23
  require 'database_consistency'
24
24
 
25
25
  # Process checks
26
- result = DatabaseConsistency.run
27
- exit result
26
+ code = DatabaseConsistency.run
27
+ exit code
@@ -38,7 +38,7 @@ module DatabaseConsistency
38
38
  config: configuration
39
39
  )
40
40
 
41
- reports.any? { |report| report.status == :fail } ? 1 : 0
41
+ reports.any? { |report| report.status == :fail } || !RescueError.empty? ? 1 : 0
42
42
  end
43
43
  end
44
44
  end
@@ -12,11 +12,14 @@ module DatabaseConsistency
12
12
  # We skip check when:
13
13
  # - association isn't a `HasOne` or `HasMany`
14
14
  # - association has `through` option
15
+ # - associated class doesn't exist
15
16
  def preconditions
16
17
  %i[
17
18
  has_one
18
19
  has_many
19
- ].include?(association.macro) && association.through_reflection.nil?
20
+ ].include?(association.macro) && association.through_reflection.nil? && association.klass
21
+ rescue NameError
22
+ false
20
23
  end
21
24
 
22
25
  # Table of possible statuses
@@ -3,8 +3,6 @@
3
3
  module DatabaseConsistency
4
4
  # The class writes error to the file
5
5
  class RescueError
6
- attr_reader :error
7
-
8
6
  private_class_method :new
9
7
 
10
8
  def self.call(error)
@@ -12,6 +10,11 @@ module DatabaseConsistency
12
10
  @singleton.call(error)
13
11
  end
14
12
 
13
+ # @return [Boolean]
14
+ def self.empty?
15
+ @singleton.nil?
16
+ end
17
+
15
18
  def initialize
16
19
  puts 'Hey, some of checks fail with an error, please open an issue on github at https://github.com/djezzzl/database_consistency.'
17
20
  puts "Attach the created file: #{filename}"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DatabaseConsistency
4
- VERSION = '0.7.1'
4
+ VERSION = '0.7.2'
5
5
  end
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: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeniy Demin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-22 00:00:00.000000000 Z
11
+ date: 2019-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord