Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix alignment in the output

* Don't show the uncompressed vs compressed size.  Just show the compressed size.
  • Loading branch information...
commit 57e62c679fcf373a744dfaa4d7b6a22f66c1528a 1 parent 403e762
@kjvarga authored
View
15 lib/sitemap_generator/builder/sitemap_file.rb
@@ -125,12 +125,23 @@ def new
# Return a summary string
def summary(opts={})
uncompressed_size = number_to_human_size(@filesize)
- compressed_size = number_to_human_size(@location.filesize)
- "+ #{'%-21s' % @location.path_in_public} #{'%13s' % @link_count} links / #{'%10s' % uncompressed_size} / #{'%10s' % compressed_size} gzipped"
+ compressed_size = number_to_human_size(@location.filesize)
+ path = ellipsis(@location.path_in_public, 47)
+ "+ #{'%-47s' % path} #{'%10s' % @link_count} links / #{'%10s' % compressed_size}"
end
protected
+ # Replace the last 3 characters of string with ... if the string is as big
+ # or bigger than max.
+ def ellipsis(string, max)
+ if string.size >= max
+ string[0, max - 3] + '...'
+ else
+ string
+ end
+ end
+
# Return the bytesize length of the string. Ruby 1.8.6 compatible.
def bytesize(string)
string.respond_to?(:bytesize) ? string.bytesize : string.length
View
3  lib/sitemap_generator/builder/sitemap_index_file.rb
@@ -51,7 +51,8 @@ def total_link_count
def summary(opts={})
uncompressed_size = number_to_human_size(@filesize)
compressed_size = number_to_human_size(@location.filesize)
- "+ #{'%-21s' % @location.path_in_public} #{'%10s' % @link_count} sitemaps / #{'%10s' % uncompressed_size} / #{'%10s' % compressed_size} gzipped"
+ path = ellipsis(@location.path_in_public, 44) # 47 - 3
+ "+ #{'%-44s' % path} #{'%10s' % @link_count} sitemaps / #{'%10s' % compressed_size}"
end
def stats_summary(opts={})
Please sign in to comment.
Something went wrong with that request. Please try again.