-
Notifications
You must be signed in to change notification settings - Fork 198
Expand file tree
/
Copy pathconfig.rb
More file actions
41 lines (33 loc) · 1.09 KB
/
config.rb
File metadata and controls
41 lines (33 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
module DataMigrate
include ActiveSupport::Configurable
class << self
def configure
yield config
end
def config
@config ||= Config.new
end
end
class Config
attr_accessor :data_migrations_table_name, :data_migrations_path, :data_template_path, :db_configuration, :spec_name, :test_support_enabled, :test_framework
DEFAULT_DATA_TEMPLATE_PATH = "data_migration.rb"
def initialize
@data_migrations_table_name = "data_migrations"
@data_migrations_path = "db/data/"
@data_template_path = DEFAULT_DATA_TEMPLATE_PATH
@db_configuration = nil
@spec_name = nil
@test_support_enabled = false
@test_framework = nil
end
def data_template_path=(value)
@data_template_path = value.tap do |path|
raise ArgumentError, "File not found: '#{path}'" unless path == DEFAULT_DATA_TEMPLATE_PATH || File.exist?(path)
end
end
def test_framework=(value)
raise ArgumentError, "Invalid test framework: #{value}" unless [:rspec, :minitest].include?(value)
@test_framework = value
end
end
end