Permalink
Browse files

if some config is omited on .stadalone_migrations, a default value is…

… used
  • Loading branch information...
1 parent 4b92a74 commit 3c13b779cf84155cde6a4a1320211981dcebb9f1 @ricardovaleriano ricardovaleriano committed Nov 11, 2011
Showing with 6 additions and 6 deletions.
  1. +6 −6 lib/standalone_migrations/configurator.rb
@@ -8,7 +8,7 @@ def initialize(options = {})
:seeds => "db/seeds.rb",
:schema => "db/schema.rb"
}
- @options = load_from_file || defaults.merge(options)
+ @options = load_from_file(defaults.dup) || defaults.merge(options)
end
def config
@@ -33,14 +33,14 @@ def configuration_file
".standalone_migrations"
end
- def load_from_file
+ def load_from_file(defaults)
return nil unless File.exists? configuration_file
config = YAML.load( IO.read(configuration_file) )
{
- :config => config["config"]["database"],
- :migrate_dir => config["db"]["migrate"],
- :seeds => config["db"]["seeds"],
- :schema => config["db"]["schema"]
+ :config => config["config"] ? config["config"]["database"] : defaults[:config],
+ :migrate_dir => config["db"] ? config["db"]["migrate"] : defaults[:migrate_dir],
+ :seeds => config["db"] ? config["db"]["seeds"] : defaults[:seeds],
+ :schema => config["db"] ? config["db"]["schema"] : defaults[:schema]
}
end

0 comments on commit 3c13b77

Please sign in to comment.