From adffdf5def3aff08a81d5c863cc72dba814ace9d Mon Sep 17 00:00:00 2001 From: David Ricciardi Date: Sat, 30 Oct 2010 20:47:02 +0000 Subject: [PATCH] ruby1.9 fixes --- lib/sinatra-s3/helpers/admin.rb | 8 ++++---- lib/sinatra-s3/s3.rb | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/sinatra-s3/helpers/admin.rb b/lib/sinatra-s3/helpers/admin.rb index 49ee458..39b3332 100644 --- a/lib/sinatra-s3/helpers/admin.rb +++ b/lib/sinatra-s3/helpers/admin.rb @@ -10,10 +10,10 @@ def login_required def number_to_human_size(size) case - when size < 1.kilobyte: '%d Bytes' % size - when size < 1.megabyte: '%.1f KB' % (size / 1.0.kilobyte) - when size < 1.gigabyte: '%.1f MB' % (size / 1.0.megabyte) - when size < 1.terabyte: '%.1f GB' % (size / 1.0.gigabyte) + when size < 1.kilobyte then '%d Bytes' % size + when size < 1.megabyte then '%.1f KB' % (size / 1.0.kilobyte) + when size < 1.gigabyte then '%.1f MB' % (size / 1.0.megabyte) + when size < 1.terabyte then '%.1f GB' % (size / 1.0.gigabyte) else '%.1f TB' % (size / 1.0.terabyte) end.sub('.0', '') rescue diff --git a/lib/sinatra-s3/s3.rb b/lib/sinatra-s3/s3.rb index e992c61..b372d51 100644 --- a/lib/sinatra-s3/s3.rb +++ b/lib/sinatra-s3/s3.rb @@ -7,7 +7,11 @@ require 'openssl' require 'base64' require 'digest/sha1' -require 'md5' +if RUBY_VERSION < '1.9' + require 'md5' +else + require 'digest/md5' +end require 'haml' begin