diff --git a/Gemfile.lock b/Gemfile.lock index 5c92b5a..d0f7222 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - annotato (0.2.2) + annotato (0.2.3) rails (>= 6.0) GEM diff --git a/lib/annotato/column_formatter.rb b/lib/annotato/column_formatter.rb index bc9823f..9ca504a 100644 --- a/lib/annotato/column_formatter.rb +++ b/lib/annotato/column_formatter.rb @@ -26,11 +26,12 @@ def self.format(model, connection) type = col.sql_type # Build the left-hand side and calculate indent. - left = "# %-#{name_width}s :%-#{type_width}s" % [name, type] - # " default(" is 9 chars; +2 gives the extra gap. + # Strip trailing padding spaces immediately — output must never have trailing whitespace. + left = ("# %-#{name_width}s :%-#{type_width}s" % [name, type]).rstrip + # indent_size aligns multiline default content under the opening "default(" token. indent_size = left.length + 1 indent_str = " " * indent_size - closing_indent_str = " " * (indent_size - 2) + closing_indent_str = " " * (indent_size - 2) # Gather all options, pulling out default_lines if multiline. opts = [] @@ -64,10 +65,9 @@ def self.format(model, connection) opts_str = opts.join(", ") line = opts_str.empty? ? left : "#{left} #{opts_str}" if line.length > WrapHelper::MAX_LINE && !opts_str.empty? - cont_indent = " " * (left.length + 1) - [left, "# #{cont_indent}#{opts_str}"] + [left, "# #{opts_str}"] else - [line.rstrip] + [line] end end end diff --git a/lib/annotato/version.rb b/lib/annotato/version.rb index 8f3ae77..5ec7b83 100644 --- a/lib/annotato/version.rb +++ b/lib/annotato/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Annotato - VERSION = "0.2.2" + VERSION = "0.2.3" end