lib/travis/tools/formatter.rb in travis-1.5.9.travis.360.4 vs lib/travis/tools/formatter.rb in travis-1.5.9.travis.361.4
- old
+ new
@@ -18,9 +18,21 @@
output << "#{seconds} sec" if seconds > 0 or output.empty?
output << suffix if suffix
output.join(" ")
end
+ def file_size(input, human = true)
+ return "#{input} B" unless human
+ format = "B"
+ iec = %w[KiB MiB GiB TiB PiB EiB ZiB YiB]
+ while human and input > 512 and iec.any?
+ input /= 1024.0
+ format = iec.shift
+ end
+ input = input.round(2) if input.is_a? Float
+ "#{input} #{format}"
+ end
+
def time(time)
return "not yet" if time.nil? # or time > Time.now
#return duration(time, "ago") if Time.now - time < DAY
time.localtime.strftime(TIME_FORMAT)
end
\ No newline at end of file