verbose output

This commit is contained in:
Christian Mehlmauer
2013-12-08 00:52:07 +01:00
parent 1e1fdee5a7
commit c107422353
9 changed files with 29 additions and 20 deletions

View File

@@ -177,3 +177,10 @@ end
def count_file_lines(file)
`wc -l #{file.shellescape}`.split[0].to_i
end
# Truncates a string to a specific length and adds ... at the end
def truncate(input, size, trailing = '...')
padded_length = size - trailing.length - 2 # ... + space + index 0
return input if input.nil? or size <= trailing.length or size <= 0 or input.length <= size
return "#{input[0...padded_length]}#{trailing}"
end