debian-mirror-gitlab/rubocop/migration_helpers.rb

18 lines
534 B
Ruby
Raw Normal View History

2016-08-24 12:49:21 +05:30
module RuboCop
# Module containing helper methods for writing migration cops.
module MigrationHelpers
# Returns true if the given node originated from the db/migrate directory.
def in_migration?(node)
2017-09-10 17:25:29 +05:30
dirname = File.dirname(node.location.expression.source_buffer.name)
dirname.end_with?('db/migrate', 'db/post_migrate')
2016-08-24 12:49:21 +05:30
end
2018-03-17 18:26:18 +05:30
def in_post_deployment_migration?(node)
dirname = File.dirname(node.location.expression.source_buffer.name)
dirname.end_with?('db/post_migrate')
end
2016-08-24 12:49:21 +05:30
end
end