Created
October 2, 2014 20:05
-
-
Save remi/22e3b7489315c65d543b to your computer and use it in GitHub Desktop.
Remove the useless and harmful ActiveRecord::SchemaDumper vertical alignment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove the useless and harmful ActiveRecord::SchemaDumper vertical alignment | |
module ActiveRecord | |
class SchemaDumper | |
def table_with_sane_alignment(table, main_stream) | |
# Call the original method to populate our custom stream | |
stream = StringIO.new | |
table_without_sane_alignment(table, stream) | |
# Rewind the stream and remove useless whitespace | |
content = stream.tap(&:rewind).read.gsub(/(?<!^)(?<!\s)[ ]{2,}/, ' ') | |
main_stream.print(content) | |
# Rails expects the `#table` method to return the main stream | |
main_stream | |
end | |
alias_method_chain :table, :sane_alignment | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment