migration_helpers.rb 534 Bytes
Newer Older
1 2 3 4 5
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)
6 7 8
      dirname = File.dirname(node.location.expression.source_buffer.name)

      dirname.end_with?('db/migrate', 'db/post_migrate')
9
    end
10 11 12 13 14 15

    def in_post_deployment_migration?(node)
      dirname = File.dirname(node.location.expression.source_buffer.name)

      dirname.end_with?('db/post_migrate')
    end
16 17
  end
end