vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb in refinerycms-0.9.7.14 vs vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb in refinerycms-0.9.7.15

- old
+ new

@@ -235,19 +235,19 @@ attachment_options[:thumbnail_class] end # Copies the given file path to a new tempfile, returning the closed tempfile. def copy_to_temp_file(file, temp_base_name) - returning Tempfile.new(temp_base_name, Technoweenie::AttachmentFu.tempfile_path) do |tmp| + Tempfile.new(temp_base_name, Technoweenie::AttachmentFu.tempfile_path).tap do |tmp| tmp.close FileUtils.cp file, tmp.path end end # Writes the given data to a new tempfile, returning the closed tempfile. def write_to_temp_file(data, temp_base_name) - returning Tempfile.new(temp_base_name, Technoweenie::AttachmentFu.tempfile_path) do |tmp| + Tempfile.new(temp_base_name, Technoweenie::AttachmentFu.tempfile_path).tap do |tmp| tmp.binmode tmp.write data tmp.close end end @@ -286,11 +286,11 @@ end # Creates or updates the thumbnail for the current attachment. def create_or_update_thumbnail(temp_file, file_name_suffix, *size) thumbnailable? || raise(ThumbnailError.new("Can't create a thumbnail if the content type is not an image or there is no parent_id column")) - returning find_or_initialize_thumbnail(file_name_suffix) do |thumb| + find_or_initialize_thumbnail(file_name_suffix).tap do |thumb| thumb.temp_paths.unshift temp_file thumb.send(:'attributes=', { :content_type => content_type, :filename => thumbnail_name_for(file_name_suffix), :thumbnail_resize_options => size @@ -407,10 +407,10 @@ "#{rand Time.now.to_i}#{filename || 'attachment'}" end def sanitize_filename(filename) return unless filename - returning filename.strip do |name| + filename.strip.tap do |name| # NOTE: File.basename doesn't work right with Windows paths on Unix # get only the filename, not the whole path name.gsub! /^.*(\\|\/)/, '' # Finally, replace all non alphanumeric, underscore or periods with underscore