Sha256: d64d96d3b000b09bd3cd4812eaffe7a6f99456338423f3d64abb6553335b6a35

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

require 'singleton'

module ActiveRecord
  module Dbt
    class Config
      include Singleton

      include ActiveRecord::Dbt::Configuration::DataSync
      include ActiveRecord::Dbt::Configuration::Logger
      include ActiveRecord::Dbt::Configuration::Parser
      include ActiveRecord::Dbt::Configuration::UsedDbtPackage

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

      attr_writer :config_directory_path, :export_directory_path

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

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

      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

      def config_directory_path
        @config_directory_path ||= DEFAULT_CONFIG_DIRECTORY_PATH
      end

      def export_directory_path
        @export_directory_path ||= DEFAULT_EXPORT_DIRECTORY_PATH
      end

      class SourceNameIsNullError < StandardError; end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activerecord-dbt-0.1.0 lib/active_record/dbt/config.rb