lib/lockbox/carrier_wave_extensions.rb in lockbox-0.6.0 vs lib/lockbox/carrier_wave_extensions.rb in lockbox-0.6.1

- old
+ new

@@ -30,13 +30,18 @@ # use size of plaintext since read and content type use plaintext def size read.bytesize end - # based on CarrierWave::SanitizedFile#mime_magic_content_type def content_type - MimeMagic.by_magic(read).try(:type) || "invalid/invalid" + if CarrierWave::VERSION.to_i >= 2 + # based on CarrierWave::SanitizedFile#mime_magic_content_type + MimeMagic.by_magic(read).try(:type) || "invalid/invalid" + else + # uses filename + super + end end # disable processing since already processed def rotate_encryption! io = Lockbox::IO.new(read) @@ -96,9 +101,12 @@ end end end if CarrierWave::VERSION.to_i > 2 - raise "CarrierWave version not supported in this version of Lockbox: #{CarrierWave::VERSION}" + raise "CarrierWave version (#{CarrierWave::VERSION}) not supported in this version of Lockbox (#{Lockbox::VERSION})" +elsif CarrierWave::VERSION.to_i < 1 + # TODO raise error in 0.7.0 + warn "CarrierWave version (#{CarrierWave::VERSION}) not supported in this version of Lockbox (#{Lockbox::VERSION})" end CarrierWave::Uploader::Base.extend(Lockbox::CarrierWaveExtensions)