activerecord-dbt 0.3.0 → 0.4.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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +103 -77
  3. data/lib/active_record/dbt/column/{test.rb → data_test.rb} +16 -16
  4. data/lib/active_record/dbt/column/{testable/accepted_values_testable.rb → data_testable/accepted_values_data_testable.rb} +2 -2
  5. data/lib/active_record/dbt/column/{testable/not_null_testable.rb → data_testable/not_null_data_testable.rb} +2 -2
  6. data/lib/active_record/dbt/column/{testable/relationships_testable.rb → data_testable/relationships_data_testable.rb} +3 -3
  7. data/lib/active_record/dbt/column/{testable/unique_testable.rb → data_testable/unique_data_testable.rb} +2 -2
  8. data/lib/active_record/dbt/column/{column.rb → yml.rb} +7 -7
  9. data/lib/active_record/dbt/configuration/i18n_configuration.rb +1 -1
  10. data/lib/active_record/dbt/dbt_package/dbt_utils/table/{testable/unique_combination_of_columns_testable.rb → data_testable/unique_combination_of_columns_data_testable.rb} +2 -2
  11. data/lib/active_record/dbt/dbt_package/dbterd/column/{testable → data_testable}/relationships_meta_relationship_type.rb +2 -2
  12. data/lib/active_record/dbt/factory/columns/yml_factory.rb +33 -0
  13. data/lib/active_record/dbt/factory/model/staging/yml_factory.rb +24 -0
  14. data/lib/active_record/dbt/factory/source/yml_factory.rb +17 -0
  15. data/lib/active_record/dbt/factory/table/yml_factory.rb +18 -0
  16. data/lib/active_record/dbt/factory/tables/yml_factory.rb +17 -0
  17. data/lib/active_record/dbt/model/staging/base.rb +1 -1
  18. data/lib/active_record/dbt/model/staging/yml.rb +5 -5
  19. data/lib/active_record/dbt/seed/enum/base.rb +1 -1
  20. data/lib/active_record/dbt/seed/enum/yml.rb +8 -8
  21. data/lib/active_record/dbt/source/yml.rb +8 -4
  22. data/lib/active_record/dbt/table/{test.rb → data_test.rb} +3 -3
  23. data/lib/active_record/dbt/table/yml.rb +6 -6
  24. data/lib/active_record/dbt/version.rb +1 -1
  25. data/lib/generators/active_record/dbt/config/templates/source_config.yml.tt +2 -2
  26. data/lib/generators/active_record/dbt/enum/USAGE +2 -2
  27. data/lib/generators/active_record/dbt/initializer/templates/dbt.rb +9 -7
  28. data/lib/generators/active_record/dbt/source/USAGE +1 -1
  29. data/lib/generators/active_record/dbt/source/source_generator.rb +3 -4
  30. data/lib/generators/active_record/dbt/staging_model/USAGE +2 -2
  31. data/lib/generators/active_record/dbt/staging_model/staging_model_generator.rb +1 -1
  32. metadata +16 -16
  33. data/lib/active_record/dbt/factory/columns_factory.rb +0 -31
  34. data/lib/active_record/dbt/factory/model/staging_factory.rb +0 -22
  35. data/lib/active_record/dbt/factory/source_factory.rb +0 -15
  36. data/lib/active_record/dbt/factory/table_factory.rb +0 -16
  37. data/lib/active_record/dbt/factory/tables_factory.rb +0 -15
@@ -3,30 +3,30 @@
3
3
  module ActiveRecord
4
4
  module Dbt
5
5
  module Column
6
- class Column
6
+ class Yml
7
7
  include ActiveRecord::Dbt::DataType::Mapper
8
8
  include ActiveRecord::Dbt::I18nWrapper::Translate
9
9
 
10
- attr_reader :table_name, :column, :column_test, :primary_keys
10
+ attr_reader :table_name, :column, :column_data_test, :primary_keys
11
11
 
12
12
  delegate :name, :comment, to: :column, prefix: true
13
13
  delegate :source_config, to: :@config
14
14
 
15
- def initialize(table_name, column, column_test, primary_keys: [])
15
+ def initialize(table_name, column, column_data_test, primary_keys: [])
16
16
  @table_name = table_name
17
17
  @column = column
18
- @column_test = column_test
18
+ @column_data_test = column_data_test
19
19
  @primary_keys = primary_keys
20
20
  @config = ActiveRecord::Dbt::Config.instance
21
21
  end
22
22
 
23
- def config
23
+ def properties
24
24
  {
25
25
  'name' => column_name,
26
26
  'description' => description,
27
27
  'data_type' => data_type(column.type),
28
- **column_overrides.except(:tests),
29
- 'tests' => column_test.config
28
+ **column_overrides.except(:data_tests),
29
+ 'data_tests' => column_data_test.properties
30
30
  }.compact
31
31
  end
32
32
 
@@ -5,7 +5,7 @@ module ActiveRecord
5
5
  module Configuration
6
6
  module I18nConfiguration
7
7
  def locale=(locale = I18n.locale)
8
- I18n.load_path += Dir[Rails.root.join('config/locales/**/*.{rb,yml}')]
8
+ I18n.load_path += Rails.root.glob('config/locales/**/*.{rb,yml}')
9
9
  I18n.locale = locale
10
10
  end
11
11
  end
@@ -5,8 +5,8 @@ module ActiveRecord
5
5
  module DbtPackage
6
6
  module DbtUtils
7
7
  module Table
8
- module Testable
9
- module UniqueCombinationOfColumnsTestable
8
+ module DataTestable
9
+ module UniqueCombinationOfColumnsDataTestable
10
10
  extend ActiveRecord::Dbt::RequiredMethods
11
11
 
12
12
  define_required_methods :table_name, :@config
@@ -5,7 +5,7 @@ module ActiveRecord
5
5
  module DbtPackage
6
6
  module Dbterd
7
7
  module Column
8
- module Testable
8
+ module DataTestable
9
9
  module RelationshipsMetaRelationshipType
10
10
  extend ActiveRecord::Dbt::RequiredMethods
11
11
 
@@ -89,7 +89,7 @@ module ActiveRecord
89
89
  end
90
90
 
91
91
  def association_klass(association)
92
- association.klass
92
+ association.class_name.constantize
93
93
  rescue NoMethodError
94
94
  association.options.fetch(:through).to_s.classify.constantize
95
95
  end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecord
4
+ module Dbt
5
+ module Factory
6
+ module Columns
7
+ module YmlFactory
8
+ def self.build(
9
+ table_name,
10
+ primary_keys: ActiveRecord::Base.connection.primary_keys(table_name),
11
+ foreign_keys: ActiveRecord::Base.connection.foreign_keys(table_name)
12
+ )
13
+ ActiveRecord::Base.connection.columns(table_name).map do |column|
14
+ column_data_test = ActiveRecord::Dbt::Column::DataTest.new(
15
+ table_name,
16
+ column,
17
+ primary_keys: primary_keys,
18
+ foreign_keys: foreign_keys
19
+ )
20
+
21
+ ActiveRecord::Dbt::Column::Yml.new(
22
+ table_name,
23
+ column,
24
+ column_data_test,
25
+ primary_keys: primary_keys
26
+ )
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecord
4
+ module Dbt
5
+ module Factory
6
+ module Model
7
+ module Staging
8
+ module YmlFactory
9
+ def self.build(table_name)
10
+ table_factory = ActiveRecord::Dbt::Factory::Table::YmlFactory.build(table_name)
11
+ yml = ActiveRecord::Dbt::Model::Staging::Yml.new(table_factory)
12
+ struct = Struct.new(:export_path, :dump, keyword_init: true)
13
+
14
+ struct.new(
15
+ export_path: yml.export_path,
16
+ dump: yml.dump
17
+ )
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecord
4
+ module Dbt
5
+ module Factory
6
+ module Source
7
+ module YmlFactory
8
+ def self.build
9
+ tables_factory = ActiveRecord::Dbt::Factory::Tables::YmlFactory.build
10
+
11
+ ActiveRecord::Dbt::Source::Yml.new(tables_factory)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecord
4
+ module Dbt
5
+ module Factory
6
+ module Table
7
+ module YmlFactory
8
+ def self.build(table_name)
9
+ table_data_test = ActiveRecord::Dbt::Table::DataTest.new(table_name)
10
+ columns = ActiveRecord::Dbt::Factory::Columns::YmlFactory.build(table_name)
11
+
12
+ ActiveRecord::Dbt::Table::Yml.new(table_name, table_data_test, columns)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecord
4
+ module Dbt
5
+ module Factory
6
+ module Tables
7
+ module YmlFactory
8
+ def self.build
9
+ ActiveRecord::Base.connection.tables.sort.map do |table_name|
10
+ ActiveRecord::Dbt::Factory::Table::YmlFactory.build(table_name)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -36,7 +36,7 @@ module ActiveRecord
36
36
  private
37
37
 
38
38
  def basename
39
- "#{export_directory_path}/#{model_name}"
39
+ "#{export_directory_path}/models/staging/#{source_name}/#{model_name}"
40
40
  end
41
41
 
42
42
  def model_name
@@ -22,18 +22,18 @@ module ActiveRecord
22
22
  end
23
23
 
24
24
  def dump
25
- YAML.dump(model_config.deep_stringify_keys)
25
+ YAML.dump(properties.deep_stringify_keys)
26
26
  end
27
27
 
28
28
  private
29
29
 
30
- def model_config
30
+ def properties
31
31
  {
32
32
  'version' => 2,
33
33
  'models' => [
34
34
  {
35
35
  'name' => model_name,
36
- **table.config.except('name', 'columns'),
36
+ **table.properties.except('name', 'columns'),
37
37
  'columns' => override_columns
38
38
  }
39
39
  ]
@@ -41,7 +41,7 @@ module ActiveRecord
41
41
  end
42
42
 
43
43
  def columns
44
- @columns ||= sort_columns(table.config['columns'])
44
+ @columns ||= sort_columns(table.properties['columns'])
45
45
  end
46
46
 
47
47
  def sort_columns(columns)
@@ -79,7 +79,7 @@ module ActiveRecord
79
79
  end
80
80
 
81
81
  def add_relationship_test(column)
82
- column['tests'].push(relationships_test(column['name']))
82
+ column['data_tests'].push(relationships_test(column['name']))
83
83
  end
84
84
 
85
85
  def rename_primary_id_in_column(column)
@@ -19,7 +19,7 @@ module ActiveRecord
19
19
  private
20
20
 
21
21
  def basename
22
- "#{export_directory_path}/#{seed_name}"
22
+ "#{export_directory_path}/seeds/#{source_name}/#{seed_name}"
23
23
  end
24
24
 
25
25
  def seed_name
@@ -5,8 +5,8 @@ module ActiveRecord
5
5
  module Seed
6
6
  module Enum
7
7
  class Yml
8
- include ActiveRecord::Dbt::Column::Testable::UniqueTestable
9
- include ActiveRecord::Dbt::Column::Testable::NotNullTestable
8
+ include ActiveRecord::Dbt::Column::DataTestable::UniqueDataTestable
9
+ include ActiveRecord::Dbt::Column::DataTestable::NotNullDataTestable
10
10
  include ActiveRecord::Dbt::DataType::Mapper
11
11
  include ActiveRecord::Dbt::I18nWrapper::Translate
12
12
  include ActiveRecord::Dbt::Seed::Enum::Base
@@ -20,12 +20,12 @@ module ActiveRecord
20
20
  end
21
21
 
22
22
  def dump
23
- YAML.dump(seed_config.deep_stringify_keys)
23
+ YAML.dump(properties.deep_stringify_keys)
24
24
  end
25
25
 
26
26
  private
27
27
 
28
- def seed_config
28
+ def properties
29
29
  {
30
30
  'version' => 2,
31
31
  'seeds' => [
@@ -81,7 +81,7 @@ module ActiveRecord
81
81
  {
82
82
  'name' => "#{enum_column_name}_before_type_of_cast",
83
83
  'description' => translated_attribute_name,
84
- 'tests' => tests
84
+ 'data_tests' => data_tests
85
85
  }.compact
86
86
  end
87
87
 
@@ -89,7 +89,7 @@ module ActiveRecord
89
89
  {
90
90
  'name' => "#{enum_column_name}_key",
91
91
  'description' => "#{translated_attribute_name}(key)",
92
- 'tests' => tests
92
+ 'data_tests' => data_tests
93
93
  }.compact
94
94
  end
95
95
 
@@ -99,13 +99,13 @@ module ActiveRecord
99
99
  {
100
100
  'name' => "#{enum_column_name}_#{locale}",
101
101
  'description' => "#{translated_attribute_name}(#{locale})",
102
- 'tests' => tests
102
+ 'data_tests' => data_tests
103
103
  }.compact
104
104
  )
105
105
  end
106
106
  end
107
107
 
108
- def tests
108
+ def data_tests
109
109
  [
110
110
  unique_test,
111
111
  not_null_test
@@ -6,20 +6,24 @@ module ActiveRecord
6
6
  class Yml
7
7
  attr_reader :tables
8
8
 
9
- delegate :source_config, to: :@config
9
+ delegate :source_config, :export_directory_path, :source_name, to: :@config
10
10
 
11
11
  def initialize(tables)
12
12
  @tables = tables
13
13
  @config = ActiveRecord::Dbt::Config.instance
14
14
  end
15
15
 
16
+ def export_path
17
+ "#{export_directory_path}/models/sources/#{source_name}/src_#{source_name}.yml"
18
+ end
19
+
16
20
  def dump
17
- YAML.dump(config.deep_stringify_keys)
21
+ YAML.dump(properties.deep_stringify_keys)
18
22
  end
19
23
 
20
24
  private
21
25
 
22
- def config
26
+ def properties
23
27
  {
24
28
  'version' => 2,
25
29
  'sources' => [
@@ -33,7 +37,7 @@ module ActiveRecord
33
37
  end
34
38
 
35
39
  def tables_properties
36
- tables.map(&:config)
40
+ tables.map(&:properties)
37
41
  end
38
42
  end
39
43
  end
@@ -3,12 +3,12 @@
3
3
  module ActiveRecord
4
4
  module Dbt
5
5
  module Table
6
- class Test
7
- include ActiveRecord::Dbt::DbtPackage::DbtUtils::Table::Testable::UniqueCombinationOfColumnsTestable
6
+ class DataTest
7
+ include ActiveRecord::Dbt::DbtPackage::DbtUtils::Table::DataTestable::UniqueCombinationOfColumnsDataTestable
8
8
 
9
9
  include ActiveRecord::Dbt::Table::Base
10
10
 
11
- def config
11
+ def properties
12
12
  [
13
13
  *unique_combination_of_columns_test
14
14
  ].compact.presence
@@ -7,20 +7,20 @@ module ActiveRecord
7
7
  include ActiveRecord::Dbt::I18nWrapper::Translate
8
8
  include ActiveRecord::Dbt::Table::Base
9
9
 
10
- attr_reader :table_test, :columns
10
+ attr_reader :table_data_test, :columns
11
11
 
12
12
  delegate :source_config, to: :@config
13
13
 
14
- def initialize(table_name, table_test, columns)
14
+ def initialize(table_name, table_data_test, columns)
15
15
  super(table_name)
16
- @table_test = table_test
16
+ @table_data_test = table_data_test
17
17
  @columns = columns
18
18
  end
19
19
 
20
- def config
20
+ def properties
21
21
  {
22
22
  **table_properties,
23
- 'columns' => columns.map(&:config)
23
+ 'columns' => columns.map(&:properties)
24
24
  }.compact
25
25
  end
26
26
 
@@ -31,7 +31,7 @@ module ActiveRecord
31
31
  'name' => table_name,
32
32
  'description' => description,
33
33
  **table_overrides.except(:columns),
34
- 'tests' => table_test.config
34
+ 'data_tests' => table_data_test.properties
35
35
  }
36
36
  end
37
37
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveRecord
4
4
  module Dbt
5
- VERSION = '0.3.0'
5
+ VERSION = '0.4.0'
6
6
  end
7
7
  end
@@ -11,7 +11,7 @@ table_overrides:
11
11
  meta: {<dictionary>}
12
12
  identifier: <table_name>
13
13
  loaded_at_field: <column_name>
14
- tests:
14
+ data_tests:
15
15
  - <test>
16
16
  tags: [<string>]
17
17
  freshness:
@@ -31,7 +31,7 @@ table_overrides:
31
31
  <column_name>:
32
32
  meta: {<dictionary>}
33
33
  quote: true | false
34
- tests:
34
+ data_tests:
35
35
  - <test>
36
36
  tags: [<string>]
37
37
 
@@ -5,5 +5,5 @@ Example:
5
5
  bin/rails generate active_record:dbt:enum TABLE_NAME ENUM_COLUMN_NAME
6
6
 
7
7
  This will create:
8
- #{export_directory_path}/seed_#{source_name}__#{table_name_singularize}_enum_#{enum_pluralized}.csv
9
- #{export_directory_path}/seed_#{source_name}__#{table_name_singularize}_enum_#{enum_pluralized}.yml
8
+ #{export_directory_path}/seeds/#{source_name}/seed_#{source_name}__#{table_name_singularize}_enum_#{enum_pluralized}.csv
9
+ #{export_directory_path}/seeds/#{source_name}/seed_#{source_name}__#{table_name_singularize}_enum_#{enum_pluralized}.yml
@@ -1,11 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_record/dbt'
3
+ if Rails.env.development?
4
+ require 'active_record/dbt'
4
5
 
5
- ActiveRecord::Dbt.configure do |c|
6
- c.config_directory_path = 'lib/dbt'
7
- c.export_directory_path = 'doc/dbt'
8
- c.dwh_platform = 'bigquery'
9
- c.data_sync_delayed = false
10
- c.used_dbt_package_names = []
6
+ ActiveRecord::Dbt.configure do |c|
7
+ c.config_directory_path = 'lib/dbt'
8
+ c.export_directory_path = 'doc/dbt'
9
+ c.dwh_platform = 'bigquery'
10
+ c.data_sync_delayed = false
11
+ c.used_dbt_package_names = []
12
+ end
11
13
  end
@@ -5,4 +5,4 @@ Example:
5
5
  bin/rails generate active_record:dbt:source
6
6
 
7
7
  This will create:
8
- #{export_directory_path}/src_#{source_name}.yml
8
+ #{export_directory_path}/models/sources/#{source_name}/src_#{source_name}.yml
@@ -7,14 +7,13 @@ module ActiveRecord
7
7
  source_root File.expand_path('templates', __dir__)
8
8
 
9
9
  def create_source_yml_file
10
- create_file "#{config.export_directory_path}/src_#{config.source_name}.yml",
11
- ActiveRecord::Dbt::Factory::SourceFactory.build
10
+ create_file yml.export_path, yml.dump
12
11
  end
13
12
 
14
13
  private
15
14
 
16
- def config
17
- @config ||= ActiveRecord::Dbt::Config.instance
15
+ def yml
16
+ @yml ||= ActiveRecord::Dbt::Factory::Source::YmlFactory.build
18
17
  end
19
18
  end
20
19
  end
@@ -5,5 +5,5 @@ Example:
5
5
  bin/rails generate active_record:dbt:staging_model TABLE_NAME
6
6
 
7
7
  This will create:
8
- #{export_directory_path}/stg_#{source_name}__#{table_name}.sql
9
- #{export_directory_path}/stg_#{source_name}__#{table_name}.yml
8
+ #{export_directory_path}/models/staging/#{source_name}/stg_#{source_name}__#{table_name}.sql
9
+ #{export_directory_path}/models/staging/#{source_name}/stg_#{source_name}__#{table_name}.yml
@@ -21,7 +21,7 @@ module ActiveRecord
21
21
  end
22
22
 
23
23
  def yml
24
- @yml ||= ActiveRecord::Dbt::Factory::Model::StagingFactory.build(name)
24
+ @yml ||= ActiveRecord::Dbt::Factory::Model::Staging::YmlFactory.build(name)
25
25
  end
26
26
 
27
27
  def source_paths
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-dbt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - yamotech
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-14 00:00:00.000000000 Z
11
+ date: 2024-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -64,12 +64,12 @@ files:
64
64
  - README.md
65
65
  - Rakefile
66
66
  - lib/active_record/dbt.rb
67
- - lib/active_record/dbt/column/column.rb
68
- - lib/active_record/dbt/column/test.rb
69
- - lib/active_record/dbt/column/testable/accepted_values_testable.rb
70
- - lib/active_record/dbt/column/testable/not_null_testable.rb
71
- - lib/active_record/dbt/column/testable/relationships_testable.rb
72
- - lib/active_record/dbt/column/testable/unique_testable.rb
67
+ - lib/active_record/dbt/column/data_test.rb
68
+ - lib/active_record/dbt/column/data_testable/accepted_values_data_testable.rb
69
+ - lib/active_record/dbt/column/data_testable/not_null_data_testable.rb
70
+ - lib/active_record/dbt/column/data_testable/relationships_data_testable.rb
71
+ - lib/active_record/dbt/column/data_testable/unique_data_testable.rb
72
+ - lib/active_record/dbt/column/yml.rb
73
73
  - lib/active_record/dbt/config.rb
74
74
  - lib/active_record/dbt/configuration/data_sync.rb
75
75
  - lib/active_record/dbt/configuration/dwh_platform.rb
@@ -79,13 +79,13 @@ files:
79
79
  - lib/active_record/dbt/configuration/source.rb
80
80
  - lib/active_record/dbt/configuration/used_dbt_package.rb
81
81
  - lib/active_record/dbt/data_type/mapper.rb
82
- - lib/active_record/dbt/dbt_package/dbt_utils/table/testable/unique_combination_of_columns_testable.rb
83
- - lib/active_record/dbt/dbt_package/dbterd/column/testable/relationships_meta_relationship_type.rb
84
- - lib/active_record/dbt/factory/columns_factory.rb
85
- - lib/active_record/dbt/factory/model/staging_factory.rb
86
- - lib/active_record/dbt/factory/source_factory.rb
87
- - lib/active_record/dbt/factory/table_factory.rb
88
- - lib/active_record/dbt/factory/tables_factory.rb
82
+ - lib/active_record/dbt/dbt_package/dbt_utils/table/data_testable/unique_combination_of_columns_data_testable.rb
83
+ - lib/active_record/dbt/dbt_package/dbterd/column/data_testable/relationships_meta_relationship_type.rb
84
+ - lib/active_record/dbt/factory/columns/yml_factory.rb
85
+ - lib/active_record/dbt/factory/model/staging/yml_factory.rb
86
+ - lib/active_record/dbt/factory/source/yml_factory.rb
87
+ - lib/active_record/dbt/factory/table/yml_factory.rb
88
+ - lib/active_record/dbt/factory/tables/yml_factory.rb
89
89
  - lib/active_record/dbt/i18n_wrapper/translate.rb
90
90
  - lib/active_record/dbt/model/staging/base.rb
91
91
  - lib/active_record/dbt/model/staging/sql.rb
@@ -97,7 +97,7 @@ files:
97
97
  - lib/active_record/dbt/seed/enum/yml.rb
98
98
  - lib/active_record/dbt/source/yml.rb
99
99
  - lib/active_record/dbt/table/base.rb
100
- - lib/active_record/dbt/table/test.rb
100
+ - lib/active_record/dbt/table/data_test.rb
101
101
  - lib/active_record/dbt/table/yml.rb
102
102
  - lib/active_record/dbt/version.rb
103
103
  - lib/generators/active_record/dbt/config/USAGE
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActiveRecord
4
- module Dbt
5
- module Factory
6
- module ColumnsFactory
7
- def self.build(
8
- table_name,
9
- primary_keys: ActiveRecord::Base.connection.primary_keys(table_name),
10
- foreign_keys: ActiveRecord::Base.connection.foreign_keys(table_name)
11
- )
12
- ActiveRecord::Base.connection.columns(table_name).map do |column|
13
- column_test = ActiveRecord::Dbt::Column::Test.new(
14
- table_name,
15
- column,
16
- primary_keys: primary_keys,
17
- foreign_keys: foreign_keys
18
- )
19
-
20
- ActiveRecord::Dbt::Column::Column.new(
21
- table_name,
22
- column,
23
- column_test,
24
- primary_keys: primary_keys
25
- )
26
- end
27
- end
28
- end
29
- end
30
- end
31
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActiveRecord
4
- module Dbt
5
- module Factory
6
- module Model
7
- module StagingFactory
8
- def self.build(table_name)
9
- table_factory = ActiveRecord::Dbt::Factory::TableFactory.build(table_name)
10
- yml = ActiveRecord::Dbt::Model::Staging::Yml.new(table_factory)
11
- struct = Struct.new(:export_path, :dump, keyword_init: true)
12
-
13
- struct.new(
14
- export_path: yml.export_path,
15
- dump: yml.dump
16
- )
17
- end
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActiveRecord
4
- module Dbt
5
- module Factory
6
- module SourceFactory
7
- def self.build
8
- tables_factory = ActiveRecord::Dbt::Factory::TablesFactory.build
9
-
10
- ActiveRecord::Dbt::Source::Yml.new(tables_factory).dump
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActiveRecord
4
- module Dbt
5
- module Factory
6
- module TableFactory
7
- def self.build(table_name)
8
- table_test = ActiveRecord::Dbt::Table::Test.new(table_name)
9
- columns = ActiveRecord::Dbt::Factory::ColumnsFactory.build(table_name)
10
-
11
- ActiveRecord::Dbt::Table::Yml.new(table_name, table_test, columns)
12
- end
13
- end
14
- end
15
- end
16
- end