master_data_tool 0.23.0 → 0.25.0

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.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/lib/master_data_tool/config.rb +2 -6
  3. data/lib/master_data_tool/version.rb +1 -1
  4. data/lib/master_data_tool.rb +2 -0
  5. data/sig/manifest.yaml +5 -0
  6. data/sig/master_data_tool/act_as_master_data.rbs +9 -0
  7. data/sig/master_data_tool/command/dump.rbs +9 -0
  8. data/sig/master_data_tool/command/import.rbs +15 -0
  9. data/sig/master_data_tool/command/verify.rbs +15 -0
  10. data/sig/master_data_tool/config.rbs +9 -0
  11. data/sig/master_data_tool/dump/config.rbs +24 -0
  12. data/sig/master_data_tool/dump/executor.rbs +26 -0
  13. data/sig/master_data_tool/import/config.rbs +20 -0
  14. data/sig/master_data_tool/import/executor.rbs +43 -0
  15. data/sig/master_data_tool/master_data.rbs +69 -0
  16. data/sig/master_data_tool/master_data_collection.rbs +14 -0
  17. data/sig/master_data_tool/master_data_file.rbs +20 -0
  18. data/sig/master_data_tool/master_data_file_collection.rbs +22 -0
  19. data/sig/master_data_tool/master_data_status.rbs +17 -0
  20. data/sig/master_data_tool/report/core.rbs +15 -0
  21. data/sig/master_data_tool/report/default_printer.rbs +9 -0
  22. data/sig/master_data_tool/report/import_report.rbs +23 -0
  23. data/sig/master_data_tool/report/print_affected_table_report.rbs +9 -0
  24. data/sig/master_data_tool/report/printer.rbs +13 -0
  25. data/sig/master_data_tool/report/verify_report.rbs +17 -0
  26. data/sig/master_data_tool/spec_config.rbs +14 -0
  27. data/sig/master_data_tool/verify/config.rbs +21 -0
  28. data/sig/master_data_tool/verify/executor.rbs +19 -0
  29. data/sig/master_data_tool/version.rbs +3 -0
  30. data/sig/master_data_tool.rbs +10 -388
  31. metadata +48 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f6232c3b6ae362cffd34640cd73539eb95423952013d5c37d49f23e54407f075
4
- data.tar.gz: 96378ffa854e3743e75b977219e5727992c0732455f92e417d4bd428e635c7f9
3
+ metadata.gz: 5f41479288ffbabe0ecdd06a1764457c6c5041b14339d5b8f14ffb26412d3461
4
+ data.tar.gz: a9d0f6847ac1edb2207455e7342593f5b1b6f848b582b59c60347cd5caebd3a0
5
5
  SHA512:
6
- metadata.gz: 5d730d66002a0f74a6f1600077e30a1df4d4481eee665328fb0d2aa151763a0800112cc073165efe9e5c9df6dd50135348416c296d4b5c8d08ae5c7265c5c9cf
7
- data.tar.gz: 685e1be7c64b7b61627c08499bd43c5517e8637c203925e9b4f0e8997bdfbc9fe86c3d2d8f6a29500f8bbe754be65be409e3d806a69ba65f53d5940992ca7278
6
+ metadata.gz: d08b291ab0364d63ed20df1bde2299660276d7e51efc2d8ee262c4b2d5b818b9652afdd9cbb2df6c5bc1b246446b643790ca09c5702d5fdbf73582258c000d80
7
+ data.tar.gz: e8363e24888d72932f8d0e7db1784ddaa6e8a083f692da6ee4f8ba51fbaf9f8686999f42427aa385827668d25a66c8ea4505fa885019a76ae1611aa4b320601e
@@ -1,11 +1,7 @@
1
- require 'active_support/configurable'
2
-
3
1
  module MasterDataTool
4
2
  class Config
5
- include ActiveSupport::Configurable
6
-
7
- config_accessor :master_data_dir
8
- config_accessor :spec_configs
3
+ class_attribute :master_data_dir
4
+ class_attribute :spec_configs
9
5
 
10
6
  def initialize
11
7
  self.master_data_dir = nil
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MasterDataTool
4
- VERSION = "0.23.0"
4
+ VERSION = "0.25.0"
5
5
  end
@@ -2,6 +2,8 @@
2
2
 
3
3
  require 'csv'
4
4
  require 'socket'
5
+ require 'active_support'
6
+ require 'active_support/core_ext'
5
7
  require_relative "master_data_tool/version"
6
8
  require_relative "master_data_tool/act_as_master_data"
7
9
  require_relative "master_data_tool/config"
data/sig/manifest.yaml ADDED
@@ -0,0 +1,5 @@
1
+ dependencies:
2
+ - name: activerecord
3
+ - name: activesupport
4
+ - name: thor
5
+ - name: csv
@@ -0,0 +1,9 @@
1
+ module MasterDataTool
2
+ module ActAsMasterData
3
+ extend ActiveSupport::Concern
4
+
5
+ module ClassMethods
6
+ def master_data?: () -> true
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module MasterDataTool
2
+ module Command
3
+ module Dump
4
+ extend ActiveSupport::Concern
5
+
6
+ def dump: () -> nil
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ module MasterDataTool
2
+ module Command
3
+ module Import
4
+ extend ActiveSupport::Concern
5
+
6
+ def import: () -> untyped
7
+
8
+ def import_all: () -> untyped
9
+
10
+ private
11
+
12
+ def build_import_executor: (SpecConfig spec_config) -> untyped
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module MasterDataTool
2
+ module Command
3
+ module Verify
4
+ extend ActiveSupport::Concern
5
+
6
+ def verify: () -> untyped
7
+
8
+ def verify_all: () -> untyped
9
+
10
+ private
11
+
12
+ def build_verify_executor: (SpecConfig spec_config) -> untyped
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ module MasterDataTool
2
+ class Config
3
+ def initialize: () -> void
4
+
5
+ def spec_config: (String spec_name) -> SpecConfig?
6
+
7
+ def csv_dir_for: (spec_name: String, ?override_identifier: String?) -> Pathname
8
+ end
9
+ end
@@ -0,0 +1,24 @@
1
+ module MasterDataTool
2
+ module Dump
3
+ class Config
4
+ DEFAULT_IGNORE_TABLES: Array[String]
5
+ DEFAULT_IGNORE_COLUMNS: Array[String]
6
+ DEFAULT_VALUES: { ignore_empty_table: bool, ignore_tables: Array[String], ignore_column_names: Array[String], only_tables: Array[String] }
7
+
8
+ attr_accessor ignore_empty_table: bool
9
+ attr_accessor ignore_tables: Array[String]
10
+ attr_accessor ignore_column_names: Array[String]
11
+ attr_accessor only_tables: Array[String]
12
+
13
+ def initialize: (ignore_empty_table: bool, ignore_tables: Array[String], ignore_column_names: Array[String], only_tables: Array[String]) -> void
14
+
15
+ def configure: () { (Config) -> void } -> void
16
+
17
+ def ignore_tables=: (Array[String] tables) -> Array[String]
18
+
19
+ def ignore_column_names=: (Array[String] column_names) -> Array[String]
20
+
21
+ def self.default_config: () -> Config
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,26 @@
1
+ module MasterDataTool
2
+ module Dump
3
+ class Executor
4
+ class Error < Struct[untyped]
5
+ attr_accessor table: String
6
+ attr_accessor exception: StandardError
7
+ end
8
+
9
+ def initialize: (spec_config: SpecConfig, dump_config: Dump::Config, verbose: bool) -> void
10
+
11
+ def execute: () -> Array[Error]
12
+
13
+ private
14
+
15
+ attr_reader spec_config: SpecConfig
16
+ attr_reader dump_config: Dump::Config
17
+ attr_reader verbose: bool
18
+
19
+ def print_message: (String message) -> nil
20
+
21
+ def dump_to_csv: (String table) -> nil
22
+
23
+ def ignore?: (Class model_klass) -> bool
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,20 @@
1
+ module MasterDataTool
2
+ module Import
3
+ class Config
4
+ DEFAULT_VALUES: { only_tables: Array[String], except_tables: Array[String], skip_no_change: bool, ignore_foreign_key_when_delete: bool }
5
+
6
+ attr_accessor only_tables: Array[String]
7
+ attr_accessor except_tables: Array[String]
8
+ attr_accessor skip_no_change: bool
9
+ attr_accessor ignore_foreign_key_when_delete: bool
10
+
11
+ def initialize: (only_tables: Array[String], except_tables: Array[String], skip_no_change: bool, ignore_foreign_key_when_delete: bool) -> void
12
+
13
+ def skip_table?: (String table_name) -> bool
14
+
15
+ def configure: () { (Config) -> void } -> void
16
+
17
+ def self.default_config: () -> Config
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,43 @@
1
+ module MasterDataTool
2
+ module Import
3
+ class Executor
4
+ def initialize: (spec_config: SpecConfig, import_config: Import::Config?, verify_config: Verify::Config?, dry_run: bool, verify: bool, silent: bool, override_identifier: String?, report_printer: Report::Printer?) -> void
5
+
6
+ def execute: () -> nil
7
+
8
+ private
9
+
10
+ attr_reader spec_config: SpecConfig
11
+ attr_reader import_config: Import::Config
12
+ attr_reader verify_config: Verify::Config
13
+ attr_reader dry_run: bool
14
+ attr_reader verify: bool
15
+ attr_reader silent: bool
16
+ attr_reader override_identifier: String?
17
+ attr_reader report_printer: Report::DefaultPrinter
18
+ attr_reader master_data_statuses_by_name: Hash[String, MasterDataStatus]
19
+
20
+ def load_master_data_statuses: () -> Hash[String, MasterDataStatus]
21
+
22
+ def print_execute_options: () -> nil
23
+
24
+ def build_master_data_collection: () -> MasterDataCollection
25
+
26
+ def import_all!: (MasterDataCollection master_data_collection) -> untyped
27
+
28
+ def transaction: -> untyped
29
+
30
+ def verify_all!: (MasterDataCollection master_data_collection) -> untyped
31
+
32
+ def save_master_data_statuses!: (MasterDataCollection master_data_collection) -> untyped
33
+
34
+ def print_affected_tables: (MasterDataCollection master_data_collection) -> untyped
35
+
36
+ def load_skip_table?: (MasterDataFile master_data_file) -> bool
37
+
38
+ def extract_master_data_csv_paths: () -> Array[Pathname]
39
+
40
+ def overridden_master_data_csv_paths: () -> Array[Pathname]
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,69 @@
1
+ module MasterDataTool
2
+ class MasterData
3
+ @affected: bool
4
+ @before_count: Integer
5
+ @after_count: Integer
6
+
7
+ BULK_INSERT_SIZE: Integer
8
+
9
+ attr_reader master_data_file: MasterDataFile
10
+ attr_reader model_klass: Class
11
+ attr_reader columns: Array[String]
12
+ attr_reader spec_config: SpecConfig
13
+
14
+ def initialize: (spec_config: SpecConfig, master_data_file: MasterDataFile, model_klass: Class) -> void
15
+
16
+ def self.build: (spec_config: SpecConfig, master_data_file: MasterDataFile, ?load: bool) -> MasterData
17
+
18
+ def basename: () -> Pathname
19
+
20
+ def load: () -> true
21
+
22
+ def import_records: () -> Array[ActiveRecord::Base]
23
+
24
+ def affected_records: () -> Array[ActiveRecord::Base]
25
+
26
+ def new_records: () -> Array[ActiveRecord::Base]
27
+
28
+ def updated_records: () -> Array[ActiveRecord::Base]
29
+
30
+ def no_change_records: () -> Array[ActiveRecord::Base]
31
+
32
+ def deleted_records: () -> Array[ActiveRecord::Base]
33
+
34
+ def loaded?: () -> bool
35
+
36
+ def affected?: () -> bool
37
+
38
+ def before_count: () -> Integer
39
+
40
+ def after_count: () -> Integer
41
+
42
+ def table_name: () -> String
43
+
44
+ def import!: (import_config: Import::Config, ?dry_run: bool) -> Report::ImportReport
45
+
46
+ def verify!: (verify_config: Verify::Config, ?ignore_fail: bool) -> Report::VerifyReport
47
+
48
+ def print_affected_table: () -> Report::PrintAffectedTableReport?
49
+
50
+ private
51
+
52
+ attr_writer loaded: bool
53
+ attr_writer columns: Array[String]
54
+ attr_writer new_records: Array[ActiveRecord::Base]
55
+ attr_writer updated_records: Array[ActiveRecord::Base]
56
+ attr_writer no_change_records: Array[ActiveRecord::Base]
57
+ attr_writer deleted_records: Array[ActiveRecord::Base]
58
+
59
+ def decide_preload_associations: (Verify::Config verify_config) -> Array[String]
60
+
61
+ def decide_eager_load_associations: (Verify::Config verify_config) -> Array[String]
62
+
63
+ def build_records_from_csv: (untyped csv, Hash[Integer, ActiveRecord::Base] old_records_by_id) -> Hash[Integer, ActiveRecord::Base]
64
+
65
+ def enable_foreign_key_checks: () -> void
66
+
67
+ def disable_foreign_key_checks: () -> void
68
+ end
69
+ end
@@ -0,0 +1,14 @@
1
+ module MasterDataTool
2
+ class MasterDataCollection
3
+ @collection: Array[MasterData]
4
+
5
+ def initialize: () -> void
6
+
7
+ def append: (master_data: MasterData) -> Array[MasterData]
8
+
9
+ def each: () { (MasterData) -> void } -> void
10
+ | () -> Enumerator[MasterData, void]
11
+
12
+ def to_a: () -> Array[MasterData]
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ module MasterDataTool
2
+ class MasterDataFile
3
+ attr_reader spec_name: String
4
+ attr_reader table_name: String
5
+ attr_reader path: Pathname
6
+ attr_reader override_identifier: String?
7
+
8
+ def initialize: (spec_name: String, table_name: String, path: Pathname, override_identifier: String?) -> void
9
+
10
+ def self.build: (spec_name: String, path: Pathname, override_identifier: String?) -> MasterDataFile
11
+
12
+ def basename: () -> Pathname
13
+
14
+ def ==: (Integer | Object other) -> bool
15
+
16
+ alias eql? ==
17
+
18
+ def hash: () -> Integer
19
+ end
20
+ end
@@ -0,0 +1,22 @@
1
+ module MasterDataTool
2
+ class MasterDataFileCollection
3
+ def initialize: (spec_name: String, ?override_identifier: String?) -> void
4
+
5
+ def to_a: () -> Array[MasterDataFile]
6
+
7
+ def each: () { (MasterDataFile) -> void } -> void
8
+ | () -> Enumerator[MasterDataFile, void]
9
+
10
+ private
11
+
12
+ attr_reader spec_name: String
13
+ attr_reader override_identifier: String?
14
+ attr_reader collection: Array[MasterDataFile]
15
+
16
+ def build: () -> untyped
17
+
18
+ def extract_master_data_csv_paths: () -> untyped
19
+
20
+ def overridden_master_data_csv_paths: () -> Array[untyped]
21
+ end
22
+ end
@@ -0,0 +1,17 @@
1
+ module MasterDataTool
2
+ class MasterDataStatus < ::ActiveRecord::Base
3
+ def will_change?: (MasterDataFile master_data_file) -> bool
4
+
5
+ def model_klass: () -> Class
6
+
7
+ def self.build: (spec_name: String, master_data_file: MasterDataFile) -> MasterDataStatus
8
+
9
+ def self.import_records!: (records: Array[MasterDataStatus], ?dry_run: bool) -> nil
10
+
11
+ def self.decide_version: (Pathname csv_path) -> String
12
+
13
+ private
14
+
15
+ def self.import_columns: () -> Array[String]
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ module MasterDataTool
2
+ module Report
3
+ module Core
4
+ attr_reader master_data: MasterData
5
+
6
+ def initialize: (master_data: MasterData) -> void
7
+
8
+ def print: (printer: Printer) -> untyped
9
+
10
+ private
11
+
12
+ def convert_to_ltsv: ({ operation: :affected_table, table_name: String } items) -> String
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ module MasterDataTool
2
+ module Report
3
+ class DefaultPrinter
4
+ include Printer
5
+
6
+ def print: (message: String) -> nil
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,23 @@
1
+ module MasterDataTool
2
+ module Report
3
+ class ImportReport
4
+ include Core
5
+
6
+ def reports: () -> Hash[Symbol, Array[Hash[untyped, untyped]]]
7
+
8
+ def print: (printer: Printer) -> untyped
9
+
10
+ private
11
+
12
+ def count_report: () -> Hash[Symbol, Array[Hash[untyped, untyped]]]
13
+
14
+ def new_records_report: () -> Hash[Symbol, Array[Hash[untyped, untyped]]]
15
+
16
+ def updated_records_report: () -> Hash[Symbol, Array[Hash[untyped, untyped]]]
17
+
18
+ def no_change_records_report: () -> Hash[Symbol, Array[Hash[untyped, untyped]]]
19
+
20
+ def deleted_records_report: () -> Hash[Symbol, Array[Hash[untyped, untyped]]]
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,9 @@
1
+ module MasterDataTool
2
+ module Report
3
+ class PrintAffectedTableReport
4
+ include Core
5
+
6
+ def print: (printer: Printer) -> untyped
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ module MasterDataTool
2
+ module Report
3
+ module Printer
4
+ attr_reader spec_config: SpecConfig
5
+
6
+ attr_accessor silent: bool
7
+
8
+ def initialize: (spec_config: SpecConfig, silent: bool) -> void
9
+
10
+ def print: (message: String) -> nil
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ module MasterDataTool
2
+ module Report
3
+ class VerifyReport
4
+ include Core
5
+
6
+ attr_reader reports: Array[{ operation: :verify, table_name: String, valid: bool, id: Integer }]
7
+
8
+ def initialize: (master_data: MasterData) -> void
9
+
10
+ def append: (report: { operation: :verify, table_name: String, valid: bool, id: Integer }) -> Array[{ operation: :verify, table_name: String, valid: bool, id: Integer }]
11
+
12
+ def print: (printer: Printer) -> untyped
13
+
14
+ def self.build_verify_record_report: (master_data: MasterData, record: ActiveRecord::Base, valid: bool) -> { operation: :verify, table_name: String, valid: bool, id: Integer }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,14 @@
1
+ module MasterDataTool
2
+ class SpecConfig
3
+ attr_accessor spec_name: String
4
+ attr_accessor application_record_class: Class
5
+ attr_accessor import_config: Import::Config?
6
+ attr_accessor verify_config: Verify::Config?
7
+ attr_accessor dump_config: Dump::Config?
8
+ attr_accessor logger: Logger
9
+
10
+ def initialize: (spec_name: String, application_record_class: Class, ?import_config: Import::Config?, ?verify_config: Verify::Config?, ?dump_config: Dump::Config?, ?logger: Logger) -> void
11
+
12
+ def configure: () { (SpecConfig) -> void } -> void
13
+ end
14
+ end
@@ -0,0 +1,21 @@
1
+ module MasterDataTool
2
+ module Verify
3
+ class Config
4
+ DEFAULT_VALUES: { only_tables: Array[String], except_tables: Array[String], preload_belongs_to_associations: bool, preload_associations: Hash[Class, Array[Symbol]], eager_load_associations: Hash[Class, Array[Symbol]] }
5
+
6
+ attr_accessor only_tables: Array[String]
7
+ attr_accessor except_tables: Array[String]
8
+ attr_accessor preload_belongs_to_associations: bool
9
+ attr_accessor preload_associations: Hash[Class, Array[Symbol]]
10
+ attr_accessor eager_load_associations: Hash[Class, Array[Symbol]]
11
+
12
+ def initialize: (only_tables: Array[String], except_tables: Array[String], preload_belongs_to_associations: bool, preload_associations: Hash[Class, Array[Symbol]], eager_load_associations: Hash[Class, Array[Symbol]]) -> void
13
+
14
+ def skip_table?: (String table_name) -> bool
15
+
16
+ def configure: () { (Config) -> void } -> void
17
+
18
+ def self.default_config: () -> Config
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ module MasterDataTool
2
+ module Verify
3
+ class Executor
4
+ def initialize: (spec_config: SpecConfig, verify_config: Verify::Config?, silent: bool, override_identifier: String?, report_printer: Report::Printer?) -> void
5
+
6
+ def execute: () -> untyped
7
+
8
+ private
9
+
10
+ attr_reader spec_config: SpecConfig
11
+ attr_reader verify_config: Verify::Config
12
+ attr_reader silent: bool
13
+ attr_reader override_identifier: String?
14
+ attr_reader report_printer: Report::DefaultPrinter
15
+
16
+ def build_master_data_collection: () -> MasterDataCollection
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module MasterDataTool
2
+ VERSION: String
3
+ end
@@ -1,402 +1,24 @@
1
1
  module MasterDataTool
2
- VERSION: String
3
-
4
- module ActAsMasterData
5
- extend ActiveSupport::Concern
6
-
7
- def master_data?: () -> true
8
- end
9
-
10
- class Config
11
- include ActiveSupport::Configurable
12
-
13
- def initialize: () -> void
14
-
15
- def spec_config: (String spec_name) -> untyped
16
-
17
- def csv_dir_for: (spec_name: String, override_identifier: String?) -> Pathname
2
+ class Error < StandardError
18
3
  end
19
4
 
20
- module Dump
21
- class Config
22
- DEFAULT_IGNORE_TABLES: [String]
23
- DEFAULT_IGNORE_COLUMNS: [String]
24
- DEFAULT_VALUES: { ignore_empty_table: bool, ignore_tables: Array[String], ignore_column_names: Array[String], only_tables: Array[String] }
25
-
26
- attr_accessor ignore_empty_table: bool
27
- attr_accessor ignore_tables: Array[String]
28
- attr_accessor ignore_column_names: Array[String]
29
- attr_accessor only_tables: Array[String]
30
-
31
- def initialize: (ignore_empty_table: bool, ignore_tables: Array[String], ignore_column_names: Array[String], only_tables: Array[String]) -> void
32
-
33
- def configure: () -> Config
34
-
35
- def self.default_config: () -> Config
36
- end
37
-
38
- class Executor
39
- class Error < Struct[untyped]
40
- attr_accessor table: String
41
- attr_accessor exception: StandardError
42
- end
43
-
44
- def initialize: (spec_config: SpecConfig, dump_config: Dump::Config, verbose: bool) -> void
45
-
46
- def execute: () -> Array[Error]
47
-
48
- private
49
-
50
- attr_reader spec_config: SpecConfig
51
- attr_reader dump_config: Dump::Config
52
- attr_reader verbose: bool
53
-
54
- def print_message: (String message) -> nil
55
-
56
- def dump_to_csv: (String table) -> nil
57
-
58
- def ignore?: (Class model_klass) -> bool
59
- end
60
- end
61
-
62
- module Import
63
- class Config
64
- DEFAULT_VALUES: { only_tables: Array[String], except_tables: Array[String], skip_no_change: bool, ignore_foreign_key_when_delete: bool }
65
-
66
- attr_accessor only_tables: Array[String]
67
- attr_accessor except_tables: Array[String]
68
- attr_accessor skip_no_change: bool
69
- attr_accessor ignore_foreign_key_when_delete: bool
70
-
71
- def initialize: (only_tables: Array[String], except_tables: Array[String], skip_no_change: bool, ignore_foreign_key_when_delete: bool) -> void
72
-
73
- def skip_table?: (String table_name) -> bool
74
-
75
- def configure: () -> Config
76
-
77
- def self.default_config: () -> Config
78
- end
79
-
80
- class Executor
81
- def initialize: (spec_config: SpecConfig, import_config: Import::Config?, verify_config: Verify::Config?, dry_run: bool, verify: bool, silent: bool, override_identifier: String?, report_printer: Report::Printer?) -> void
82
-
83
- def execute: () -> nil
84
-
85
- private
86
-
87
- attr_reader spec_config: SpecConfig
88
- attr_reader import_config: Import::Config
89
- attr_reader verify_config: Verify::Config
90
- attr_reader dry_run: bool
91
- attr_reader verify: bool
92
- attr_reader silent: bool
93
- attr_reader override_identifier: String?
94
- attr_reader report_printer: Report::DefaultPrinter
95
- attr_reader master_data_statuses_by_name: Hash[String, MasterDataStatus]
96
-
97
- def load_master_data_statuses: () -> Hash[String, MasterDataStatus]
98
-
99
- def print_execute_options: () -> nil
100
-
101
- def build_master_data_collection: () -> MasterDataCollection
102
-
103
- def import_all!: (MasterDataCollection master_data_collection) -> untyped
104
-
105
- def transaction: -> untyped
106
-
107
- def verify_all!: (MasterDataCollection master_data_collection) -> untyped
108
-
109
- def save_master_data_statuses!: (MasterDataCollection master_data_collection) -> untyped
110
-
111
- def print_affected_tables: (MasterDataCollection master_data_collection) -> untyped
112
-
113
- def load_skip_table?: (MasterDataFile master_data_file) -> bool
114
-
115
- def extract_master_data_csv_paths: () -> Array[Pathname]
116
-
117
- def overridden_master_data_csv_paths: () -> Array[Pathname]
118
- end
5
+ class DryRunError < StandardError
119
6
  end
120
7
 
121
- class MasterData
122
- @affected: bool
123
- @before_count: Integer
124
- @after_count: Integer
125
-
126
- attr_reader master_data_file: MasterDataFile
127
- attr_reader model_klass: Class
128
- attr_accessor columns: Array[String]
129
- attr_reader spec_config: SpecConfig
130
- attr_writer loaded: bool
131
- attr_writer new_records: Array[ActiveRecord::Base]
132
- attr_writer updated_records: Array[ActiveRecord::Base]
133
- attr_writer no_change_records: Array[ActiveRecord::Base]
134
- attr_writer deleted_records: Array[ActiveRecord::Base]
135
-
136
- def decide_preload_associations: (Verify::Config verify_config) -> Array[String]
137
-
138
- def decide_eager_load_associations: (Verify::Config verify_config) -> Array[String]
139
-
140
- def initialize: (spec_config: SpecConfig, master_data_file: MasterDataFile, model_klass: Class) -> void
141
-
142
- def self.build: (spec_config: SpecConfig, master_data_file: MasterDataFile, load: bool) -> MasterData
143
-
144
- def basename: () -> Pathname
145
-
146
- def load: () -> true
147
-
148
- def import_records: () -> Array[ActiveRecord::Base]
149
-
150
- def affected_records: () -> Array[ActiveRecord::Base]
151
-
152
- def new_records: () -> Array[ActiveRecord::Base]
153
-
154
- def updated_records: () -> Array[ActiveRecord::Base]
155
-
156
- def no_change_records: () -> Array[ActiveRecord::Base]
157
-
158
- def deleted_records: () -> Array[ActiveRecord::Base]
159
-
160
- def loaded?: () -> bool
161
-
162
- def affected?: () -> bool
163
-
164
- def before_count: () -> Integer
165
-
166
- def after_count: () -> Integer
167
-
168
- def table_name: () -> String
169
-
170
- def import!: (import_config: Import::Config, ?dry_run: bool) -> Report::ImportReport
171
-
172
- def verify!: (verify_config: Verify::Config, ?ignore_fail: bool) -> Report::VerifyReport
173
-
174
- def print_affected_table: () -> Report::PrintAffectedTableReport
175
-
176
- private
177
-
178
- def build_records_from_csv: (untyped csv, Hash[Integer, ActiveRecord::Base] old_records_by_id) -> Hash[Integer, ActiveRecord::Base]
179
-
180
- def enable_foreign_key_checks: () -> void
181
-
182
- def disable_foreign_key_checks: () -> void
8
+ class NotLoadedError < StandardError
183
9
  end
184
10
 
185
- class MasterDataCollection
186
- @collection: Array[MasterData]
187
-
188
- def initialize: () -> void
189
-
190
- def append: (master_data: MasterData) -> Array[MasterData]
11
+ class VerifyFailed < StandardError
12
+ attr_accessor errors: untyped
191
13
 
192
- def each: () { (MasterData) -> void } -> void
193
- | () -> Enumerator[void, MasterData]
194
-
195
- def to_a: () -> Array[MasterData]
14
+ def full_messages: () -> untyped
196
15
  end
197
16
 
198
- class MasterDataFile
199
- attr_reader spec_name: String
200
- attr_reader table_name: String
201
- attr_reader path: Pathname
202
- attr_reader override_identifier: String?
203
-
204
- def initialize: (spec_name: String, table_name: String, path: Pathname, override_identifier: String?) -> void
17
+ def self.config: () -> Config
205
18
 
206
- def self.build: (spec_name: String, path: Pathname, override_identifier: String?) -> MasterDataFile
19
+ def self.configure: () { (Config) -> void } -> void
207
20
 
208
- def basename: () -> Pathname
209
-
210
- def ==: (Integer | Object other) -> bool
211
-
212
- alias eql? ==
213
-
214
- def hash: () -> Integer
215
- end
21
+ def self.resolve_table_name: (spec_name: String, csv_path: Pathname, override_identifier: String?) -> String
216
22
 
217
- class MasterDataFileCollection
218
- attr_reader collection: [MasterDataFile]
219
- attr_reader spec_name: String
220
- attr_reader override_identifier: String?
221
-
222
- def initialize: (spec_name: String, override_identifier: String?) -> void
223
-
224
- def to_a: () -> Array[MasterDataFile]
225
-
226
- def each: () { (MasterDataFile) -> void } -> void
227
- | () -> Enumerator[void, MasterDataFile]
228
-
229
- private
230
-
231
- def build: () -> untyped
232
-
233
- def extract_master_data_csv_paths: () -> untyped
234
-
235
- def overridden_master_data_csv_paths: () -> Array[untyped]
236
- end
237
-
238
- class MasterDataStatus
239
- def will_change?: (MasterData master_data_file) -> bool
240
-
241
- def model_klass: () -> Class
242
-
243
- def self.build: (spec_name: String, master_data_file: MasterDataFile) -> MasterDataStatus
244
-
245
- def self.import_records!: (records: [MasterDataStatus], dry_run: bool) -> nil
246
-
247
- def self.decide_version: (Pathname csv_path) -> String
248
-
249
- def self.import_columns: () -> Array[String]
250
- end
251
-
252
- module Report
253
- module Printer
254
- attr_reader spec_config: SpecConfig
255
-
256
- attr_accessor silent: bool
257
-
258
- def initialize: (spec_config: SpecConfig, silent: bool) -> void
259
-
260
- def print: (message: String) -> nil
261
- end
262
-
263
- class DefaultPrinter
264
- include Printer
265
-
266
- def print: (message: String) -> nil
267
- end
268
-
269
- module Core
270
- attr_reader master_data: MasterData
271
-
272
- def initialize: (master_data: MasterData) -> void
273
-
274
- def print: (printer: Printer) -> untyped
275
-
276
- private
277
-
278
- def convert_to_ltsv: ({ operation: :affected_table, table_name: String } items) -> String
279
- end
280
-
281
- class ImportReport
282
- include Core
283
-
284
- def reports: () -> Hash[Symbol, Array[Hash[untyped, untyped]]]
285
-
286
- def print: (printer: Printer) -> untyped
287
-
288
- private
289
-
290
- def count_report: () -> Hash[Symbol, Array[Hash[untyped, untyped]]]
291
-
292
- def new_records_report: () -> Hash[Symbol, Array[Hash[untyped, untyped]]]
293
-
294
- def updated_records_report: () -> Hash[Symbol, Array[Hash[untyped, untyped]]]
295
-
296
- def no_change_records_report: () -> Hash[Symbol, Array[Hash[untyped, untyped]]]
297
-
298
- def deleted_records_report: () -> Hash[Symbol, Array[Hash[untyped, untyped]]]
299
- end
300
-
301
- class VerifyReport
302
- include Core
303
-
304
- attr_reader reports: Array[{ operation: :verify, table_name: String, valid: bool, id: Integer }]
305
-
306
- def initialize: (master_data: MasterData) -> void
307
-
308
- def append: (report: { operation: :verify, table_name: String, valid: bool, id: Integer }) -> Array[{ operation: :verify, table_name: String, valid: bool, id: Integer }]
309
-
310
- def print: (printer: Printer) -> untyped
311
-
312
- def self.build_verify_record_report: (master_data: MasterData, record: ActiveRecord::Base, valid: bool) -> { operation: :verify, table_name: String, valid: bool, id: Integer }
313
- end
314
-
315
- class PrintAffectedTableReport
316
- include Core
317
-
318
- def print: (printer: Printer) -> untyped
319
- end
320
- end
321
-
322
- class SpecConfig
323
- attr_accessor spec_name: String
324
- attr_accessor application_record_class: Class
325
- attr_accessor import_config: Import::Config?
326
- attr_accessor verify_config: Verify::Config?
327
- attr_accessor dump_config: Dump::Config?
328
- attr_accessor logger: Logger
329
-
330
- def initialize: (spec_name: String, application_record_class: Class, import_config: Import::Config?, verify_config: Verify::Config?, dump_config: Dump::Config?, logger: Logger) -> void
331
-
332
- def configure: () -> SpecConfig
333
- end
334
-
335
- module Verify
336
- class Config
337
- DEFAULT_VALUES: { only_tables: Array[String], except_tables: Array[String], preload_belongs_to_associations: bool, preload_associations: Hash[Class, Array[Symbol]], eager_load_associations: Hash[Class, Array[Symbol]] }
338
-
339
- attr_accessor only_tables: Array[String]
340
- attr_accessor except_tables: Array[String]
341
- attr_accessor preload_belongs_to_associations: bool
342
- attr_accessor preload_associations: Hash[Class, Array[Symbol]]
343
- attr_accessor eager_load_associations: Hash[Class, Array[Symbol]]
344
-
345
- def initialize: (only_tables: Array[String], except_tables: Array[String], preload_belongs_to_associations: bool, preload_associations: Hash[Class, Array[Symbol]], eager_load_associations: Hash[Class, Array[Symbol]]) -> void
346
-
347
- def skip_table?: (String table_name) -> bool
348
-
349
- def configure: () -> Config
350
-
351
- def self.default_config: () -> Config
352
- end
353
-
354
- class Executor
355
- def initialize: (spec_config: SpecConfig, verify_config: Verify::Config?, silent: bool, override_identifier: String?, report_printer: Report::Printer?) -> void
356
-
357
- def execute: () -> untyped
358
-
359
- private
360
-
361
- attr_reader spec_config: SpecConfig
362
- attr_reader verify_config: Verify::Config
363
- attr_reader silent: bool
364
- attr_reader override_identifier: String?
365
- attr_reader report_printer: Report::DefaultPrinter
366
-
367
- def build_master_data_collection: () -> MasterDataCollection
368
- end
369
- end
370
-
371
- module Command
372
- module Import
373
- extend ActiveSupport::Concern
374
-
375
- def import: () -> untyped
376
-
377
- def import_all: () -> untyped
378
-
379
- private
380
-
381
- def build_import_executor: (SpecConfig spec_config) -> untyped
382
- end
383
-
384
- module Verify
385
- extend ActiveSupport::Concern
386
-
387
- def verify: () -> untyped
388
-
389
- def verify_all: () -> untyped
390
-
391
- private
392
-
393
- def build_verify_executor: (SpecConfig spec_config) -> untyped
394
- end
395
-
396
- module Dump
397
- extend ActiveSupport::Concern
398
-
399
- def dump: () -> nil
400
- end
401
- end
23
+ def self.need_skip_table?: (String table_name, Array[String] only, Array[String] except) -> bool
402
24
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: master_data_tool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.0
4
+ version: 0.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takahiro Ooishi
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-08-12 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rspec
@@ -70,16 +69,16 @@ dependencies:
70
69
  name: ridgepole
71
70
  requirement: !ruby/object:Gem::Requirement
72
71
  requirements:
73
- - - ">="
72
+ - - "~>"
74
73
  - !ruby/object:Gem::Version
75
- version: '0'
74
+ version: '3.0'
76
75
  type: :development
77
76
  prerelease: false
78
77
  version_requirements: !ruby/object:Gem::Requirement
79
78
  requirements:
80
- - - ">="
79
+ - - "~>"
81
80
  - !ruby/object:Gem::Version
82
- version: '0'
81
+ version: '3.0'
83
82
  - !ruby/object:Gem::Dependency
84
83
  name: database_cleaner-active_record
85
84
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +155,14 @@ dependencies:
156
155
  requirements:
157
156
  - - ">="
158
157
  - !ruby/object:Gem::Version
159
- version: 6.0.0
158
+ version: '7.2'
160
159
  type: :runtime
161
160
  prerelease: false
162
161
  version_requirements: !ruby/object:Gem::Requirement
163
162
  requirements:
164
163
  - - ">="
165
164
  - !ruby/object:Gem::Version
166
- version: 6.0.0
165
+ version: '7.2'
167
166
  - !ruby/object:Gem::Dependency
168
167
  name: activesupport
169
168
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +191,20 @@ dependencies:
192
191
  - - ">="
193
192
  - !ruby/object:Gem::Version
194
193
  version: '0'
194
+ - !ruby/object:Gem::Dependency
195
+ name: csv
196
+ requirement: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: '0'
201
+ type: :runtime
202
+ prerelease: false
203
+ version_requirements: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ version: '0'
195
208
  description: システムが稼働する上で最初から必要なデータ(マスタデータ)を管理するツールです。
196
209
  email:
197
210
  - taka0125@gmail.com
@@ -233,14 +246,38 @@ files:
233
246
  - lib/master_data_tool/verify/config.rb
234
247
  - lib/master_data_tool/verify/executor.rb
235
248
  - lib/master_data_tool/version.rb
249
+ - sig/manifest.yaml
236
250
  - sig/master_data_tool.rbs
251
+ - sig/master_data_tool/act_as_master_data.rbs
252
+ - sig/master_data_tool/command/dump.rbs
253
+ - sig/master_data_tool/command/import.rbs
254
+ - sig/master_data_tool/command/verify.rbs
255
+ - sig/master_data_tool/config.rbs
256
+ - sig/master_data_tool/dump/config.rbs
257
+ - sig/master_data_tool/dump/executor.rbs
258
+ - sig/master_data_tool/import/config.rbs
259
+ - sig/master_data_tool/import/executor.rbs
260
+ - sig/master_data_tool/master_data.rbs
261
+ - sig/master_data_tool/master_data_collection.rbs
262
+ - sig/master_data_tool/master_data_file.rbs
263
+ - sig/master_data_tool/master_data_file_collection.rbs
264
+ - sig/master_data_tool/master_data_status.rbs
265
+ - sig/master_data_tool/report/core.rbs
266
+ - sig/master_data_tool/report/default_printer.rbs
267
+ - sig/master_data_tool/report/import_report.rbs
268
+ - sig/master_data_tool/report/print_affected_table_report.rbs
269
+ - sig/master_data_tool/report/printer.rbs
270
+ - sig/master_data_tool/report/verify_report.rbs
271
+ - sig/master_data_tool/spec_config.rbs
272
+ - sig/master_data_tool/verify/config.rbs
273
+ - sig/master_data_tool/verify/executor.rbs
274
+ - sig/master_data_tool/version.rbs
237
275
  homepage: https://github.com/taka0125/master_data_tool
238
276
  licenses:
239
277
  - MIT
240
278
  metadata:
241
279
  homepage_uri: https://github.com/taka0125/master_data_tool
242
280
  source_code_uri: https://github.com/taka0125/master_data_tool
243
- post_install_message:
244
281
  rdoc_options: []
245
282
  require_paths:
246
283
  - lib
@@ -255,8 +292,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
255
292
  - !ruby/object:Gem::Version
256
293
  version: '0'
257
294
  requirements: []
258
- rubygems_version: 3.4.19
259
- signing_key:
295
+ rubygems_version: 3.6.9
260
296
  specification_version: 4
261
297
  summary: マスタデータの管理ツール
262
298
  test_files: []