Sha256: 0d3b15c1135b0ad211f65d57a9d27e03e60775e472de92fee104f96bcb9a8555

Contents?: true

Size: 1.58 KB

Versions: 20

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true

require 'rails'
require_relative 'real_data_tests/version'
require_relative 'real_data_tests/configuration'
require_relative 'real_data_tests/data_anonymizer'
require_relative 'real_data_tests/engine' if defined?(Rails)
require_relative 'real_data_tests/pg_dump_generator'
require_relative 'real_data_tests/record_collector'
require_relative 'real_data_tests/rspec_helper'
require_relative 'real_data_tests/test_data_builder'

module RealDataTests
  class Error < StandardError; end
  class ConfigurationError < Error; end
  class DumpFileError < Error; end

  class << self
    def configuration
      @configuration ||= Configuration.new
    end

    def configure
      yield(configuration) if block_given?
      configuration
    end

    def reset_configuration!
      @configuration = Configuration.new
    end

    def use_preset(name)
      configuration.use_preset(name)
    end

    def with_preset(name)
      previous_preset = configuration.current_preset
      configuration.use_preset(name)
      yield if block_given?
    ensure
      configuration.current_preset = previous_preset
    end

    def create_dump_file(record, name: nil)
      raise ConfigurationError, "Configuration not initialized" unless @configuration

      begin
        TestDataBuilder.new(record, name: name).create_dump_file
      rescue => e
        raise DumpFileError, "Failed to create dump file: #{e.message}"
      end
    end

    def root
      File.expand_path('../..', __FILE__)
    end

    def env
      @env ||= (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development')
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
real_data_tests-0.3.17 lib/real_data_tests.rb
real_data_tests-0.3.16 lib/real_data_tests.rb
real_data_tests-0.3.15 lib/real_data_tests.rb
real_data_tests-0.3.14 lib/real_data_tests.rb
real_data_tests-0.3.13 lib/real_data_tests.rb
real_data_tests-0.3.12 lib/real_data_tests.rb
real_data_tests-0.3.11 lib/real_data_tests.rb
real_data_tests-0.3.10 lib/real_data_tests.rb
real_data_tests-0.3.9 lib/real_data_tests.rb
real_data_tests-0.3.8 lib/real_data_tests.rb
real_data_tests-0.3.7 lib/real_data_tests.rb
real_data_tests-0.3.6 lib/real_data_tests.rb
real_data_tests-0.3.5 lib/real_data_tests.rb
real_data_tests-0.3.4 lib/real_data_tests.rb
real_data_tests-0.3.3 lib/real_data_tests.rb
real_data_tests-0.3.2 lib/real_data_tests.rb
real_data_tests-0.3.1 lib/real_data_tests.rb
real_data_tests-0.3.0 lib/real_data_tests.rb
real_data_tests-0.2.1 lib/real_data_tests.rb
real_data_tests-0.2.0 lib/real_data_tests.rb