database_consistency 1.2.0 → 1.2.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5774c6b4064a081e7a285013456b39fef68f39ec7dd536063c236d54abec3e84
|
4
|
+
data.tar.gz: 18ed6073af882e007ec6ea70a9a55fad8daa8fef755049a3070d9f68ce1377dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 575b90af564642b397b5a93d2c5a94a3b3b2fb8f6de12e40225361ebb96128df61a8d3e19fb4982986985c6bd1ae110539cc93f00688bab3b44205f7aa5f3716
|
7
|
+
data.tar.gz: 051360a87facb2062451b17c59ff596156b0211dfbf73d6e3345c1b45d470f45177c280d6dd6fb59602faa719a959534252dc4f9615378724d2a321d39c64394
|
data/bin/database_consistency
CHANGED
@@ -24,17 +24,22 @@ end
|
|
24
24
|
require 'optparse'
|
25
25
|
|
26
26
|
config = [default_config]
|
27
|
+
options = {}
|
27
28
|
opt_parser = OptionParser.new do |opts|
|
28
29
|
opts.banner = <<-DESC
|
29
30
|
Usage: database_consistency install - run installation
|
30
31
|
database_consistency [options]
|
31
32
|
DESC
|
32
33
|
|
33
|
-
opts.on('-cFILE', '--config=FILE', 'Use additional configuration file') do |f|
|
34
|
+
opts.on('-cFILE', '--config=FILE', 'Use additional configuration file.') do |f|
|
34
35
|
config << f
|
35
36
|
end
|
36
37
|
|
37
|
-
opts.on('-
|
38
|
+
opts.on('-g', '--generate-todo', 'Generate TODO file with every failing check disabled. You can pass existing configurations so the generated file will have only new failures.') do |f|
|
39
|
+
options[:todo] = true
|
40
|
+
end
|
41
|
+
|
42
|
+
opts.on('-h', '--help', 'Prints this help.') do
|
38
43
|
puts opts
|
39
44
|
exit
|
40
45
|
end
|
@@ -66,5 +71,5 @@ $LOAD_PATH.unshift(File.expand_path('lib', __dir__))
|
|
66
71
|
require 'database_consistency'
|
67
72
|
|
68
73
|
# Process checks
|
69
|
-
code = DatabaseConsistency.run(config)
|
74
|
+
code = DatabaseConsistency.run(config, **options)
|
70
75
|
exit code
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DatabaseConsistency
|
4
|
+
# The module contains formatters
|
5
|
+
module Writers
|
6
|
+
# The writer that generates to-do file
|
7
|
+
class TodoWriter < BaseWriter
|
8
|
+
def write
|
9
|
+
hash = results.each_with_object({}) do |result, hash|
|
10
|
+
next unless write?(result.status)
|
11
|
+
|
12
|
+
assign_result(hash, result)
|
13
|
+
end
|
14
|
+
|
15
|
+
File.write(file_name, hash.to_yaml)
|
16
|
+
end
|
17
|
+
|
18
|
+
def write?(status)
|
19
|
+
status == :fail
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def assign_result(hash, result)
|
25
|
+
hash[result.table_or_model_name] ||= {}
|
26
|
+
hash[result.table_or_model_name][result.column_or_attribute_name] ||= {}
|
27
|
+
hash[result.table_or_model_name][result.column_or_attribute_name][result.checker_name] = {'enabled' => false}
|
28
|
+
end
|
29
|
+
|
30
|
+
def file_name
|
31
|
+
[nil, *(1..100)].each do |number|
|
32
|
+
name = generate_file_name(number)
|
33
|
+
|
34
|
+
return name unless File.exists?(name)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def generate_file_name(number = nil)
|
39
|
+
".database_consistency.todo#{number}.yml"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/database_consistency.rb
CHANGED
@@ -10,6 +10,7 @@ require 'database_consistency/errors'
|
|
10
10
|
|
11
11
|
require 'database_consistency/writers/base_writer'
|
12
12
|
require 'database_consistency/writers/simple_writer'
|
13
|
+
require 'database_consistency/writers/todo_writer'
|
13
14
|
|
14
15
|
require 'database_consistency/databases/factory'
|
15
16
|
require 'database_consistency/databases/types/base'
|
@@ -48,16 +49,19 @@ require 'database_consistency/processors/indexes_processor'
|
|
48
49
|
# The root module
|
49
50
|
module DatabaseConsistency
|
50
51
|
class << self
|
51
|
-
def run(*args)
|
52
|
+
def run(*args, **opts)
|
52
53
|
configuration = Configuration.new(*args)
|
53
54
|
reports = Processors.reports(configuration)
|
54
55
|
|
55
|
-
|
56
|
-
reports,
|
57
|
-
config: configuration
|
58
|
-
)
|
56
|
+
if opts[:todo]
|
57
|
+
Writers::TodoWriter.write(reports, config: configuration)
|
59
58
|
|
60
|
-
|
59
|
+
0
|
60
|
+
else
|
61
|
+
Writers::SimpleWriter.write(reports, config: configuration)
|
62
|
+
|
63
|
+
reports.any? { |report| report.status == :fail } || !RescueError.empty? ? 1 : 0
|
64
|
+
end
|
61
65
|
end
|
62
66
|
end
|
63
67
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: database_consistency
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evgeniy Demin
|
@@ -180,6 +180,7 @@ files:
|
|
180
180
|
- lib/database_consistency/version.rb
|
181
181
|
- lib/database_consistency/writers/base_writer.rb
|
182
182
|
- lib/database_consistency/writers/simple_writer.rb
|
183
|
+
- lib/database_consistency/writers/todo_writer.rb
|
183
184
|
homepage: https://github.com/djezzzl/database_consistency
|
184
185
|
licenses:
|
185
186
|
- MIT
|