Class: MigrationPathService

Inherits:
Object
  • Object
show all
Defined in:
lib/schema_migration_monitor/migration_path_service.rb

Defined Under Namespace

Classes: MigrationPathNotFoundError

Constant Summary collapse

DEFAULT_MIGRATION_PATH =
'./db/migrate'
USER_CONFIG_PATH =
'.schema_migration_monitor.yml'

Class Method Summary collapse

Class Method Details

.executeObject



11
12
13
14
15
# File 'lib/schema_migration_monitor/migration_path_service.rb', line 11

def execute
  return get_user_config_path if Pathname.new(USER_CONFIG_PATH).exist?
  return DEFAULT_MIGRATION_PATH if Pathname.new(DEFAULT_MIGRATION_PATH).exist?
  raise MigrationPathNotFoundError
end

.get_user_config_pathObject



17
18
19
# File 'lib/schema_migration_monitor/migration_path_service.rb', line 17

def get_user_config_path
  YAML::load(user_config_file)['migration_path']
end

.user_config_fileObject



21
22
23
# File 'lib/schema_migration_monitor/migration_path_service.rb', line 21

def user_config_file
  File.open(USER_CONFIG_PATH)
end