Module: ActiveRecord::Dbt::Configuration::Source

Includes:
Parser
Included in:
ActiveRecord::Dbt::Config
Defined in:
lib/active_record/dbt/configuration/source.rb

Defined Under Namespace

Classes: SourceNameIsNullError

Constant Summary collapse

DEFAULT_CONFIG_DIRECTORY_PATH =
'lib/dbt'
DEFAULT_EXPORT_DIRECTORY_PATH =
'doc/dbt'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Parser

#parse_yaml

Instance Attribute Details

#config_directory_pathObject



14
15
16
# File 'lib/active_record/dbt/configuration/source.rb', line 14

def config_directory_path
  @config_directory_path ||= DEFAULT_CONFIG_DIRECTORY_PATH
end

#export_directory_pathObject



18
19
20
# File 'lib/active_record/dbt/configuration/source.rb', line 18

def export_directory_path
  @export_directory_path ||= DEFAULT_EXPORT_DIRECTORY_PATH
end

Instance Method Details

#exclude_table_namesObject



42
43
44
45
46
# File 'lib/active_record/dbt/configuration/source.rb', line 42

def exclude_table_names
  @exclude_table_names ||=
    source_config.dig(:sources, :config, :meta, :exclude, :table_names) ||
    []
end

#project_nameObject



36
37
38
39
40
# File 'lib/active_record/dbt/configuration/source.rb', line 36

def project_name
  @project_name ||=
    source_config.dig(:sources, :config, :meta, :project_name) ||
    source_name
end

#source_configObject



26
27
28
# File 'lib/active_record/dbt/configuration/source.rb', line 26

def source_config
  @source_config ||= parse_yaml(source_config_path)
end

#source_config_pathObject



22
23
24
# File 'lib/active_record/dbt/configuration/source.rb', line 22

def source_config_path
  @source_config_path ||= "#{config_directory_path}/source_config.yml"
end

#source_nameObject



30
31
32
33
34
# File 'lib/active_record/dbt/configuration/source.rb', line 30

def source_name
  @source_name ||= source_config.dig(:sources, :name).tap do |source_name|
    raise SourceNameIsNullError, "'sources.name' is required in '#{source_config_path}'." if source_name.nil?
  end
end