Sha256: c899829f62eaa7177c7e96afc7676482a192697fc06fdd6a1dd27b764af14f00

Contents?: true

Size: 983 Bytes

Versions: 1

Compression:

Stored size: 983 Bytes

Contents

module StandaloneMigrations
  class Configurator

    def initialize(options = {})
      defaults = {
        :config       => "db/config.yml",
        :migrate_dir  => "db/migrate",
        :seeds        => "db/seeds.rb",
        :schema       => "db/schema.rb"
      }
      @options = load_from_file || defaults.merge(options)
    end

    def config
      @options[:config]
    end

    def migrate_dir
      @options[:migrate_dir]
    end

    def seeds
      @options[:seeds]
    end

    def schema
      @options[:schema]
    end

    private

    def configuration_file
      ".standalone_migrations"
    end

    def load_from_file
      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]
      }
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
standalone_migrations-1.0.3 lib/standalone_migrations/configurator.rb