Class: MuleMigrations::Configurator

Inherits:
Object
  • Object
show all
Defined in:
lib/mule_migrations/configurator.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Configurator

Returns a new instance of Configurator.



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/mule_migrations/configurator.rb', line 31

def initialize(options = {})

  defaults = {
    :config       => "#{ENV["DB_NAME"]}db/config.yml",
    :migrate_dir  => "#{ENV["DB_NAME"]}db/migrate",
    :seeds        => "#{ENV["DB_NAME"]}db/seeds.rb",
    :schema       => "#{ENV["DB_NAME"]}db/schema.rb"
  }
  @options = load_from_file(defaults.dup) || defaults.merge(options)
  ENV['SCHEMA'] = File.expand_path(schema)
end

Class Method Details

.environments_config {|proxy| ... } ⇒ Object

Yields:

  • (proxy)


26
27
28
29
# File 'lib/mule_migrations/configurator.rb', line 26

def self.environments_config
  proxy = InternalConfigurationsProxy.new(load_configurations)
  yield(proxy) if block_given?
end

.load_configurationsObject



21
22
23
24
# File 'lib/mule_migrations/configurator.rb', line 21

def self.load_configurations
  @mule_configs ||= Configurator.new.config
  @environments_config ||= YAML.load(ERB.new(File.read(@mule_configs)).result).with_indifferent_access
end

Instance Method Details

#configObject



43
44
45
# File 'lib/mule_migrations/configurator.rb', line 43

def config
  @options[:config]
end

#config_for(environment) ⇒ Object



63
64
65
# File 'lib/mule_migrations/configurator.rb', line 63

def config_for(environment)
  config_for_all[environment]
end

#config_for_allObject



59
60
61
# File 'lib/mule_migrations/configurator.rb', line 59

def config_for_all
  Configurator.load_configurations.dup
end

#migrate_dirObject



47
48
49
# File 'lib/mule_migrations/configurator.rb', line 47

def migrate_dir
  @options[:migrate_dir]
end

#schemaObject



55
56
57
# File 'lib/mule_migrations/configurator.rb', line 55

def schema
  @options[:schema]
end

#seedsObject



51
52
53
# File 'lib/mule_migrations/configurator.rb', line 51

def seeds
  @options[:seeds]
end