Hi all,
There a small bug when you configure your own interpolate function :
all item are parsed successively in alphabetical order, and if you
define a new item containing a reference to a item that is already
done, it 'will stay as it.
Example :
>>Paperclip::Interpolations.all
=>["attachment", "basename", "class", "extension", "filename",
"full_path", "id", "id_partition", "rails_env", "rails_root", "style",
"timestamp", "url"]
:full_path is my own interpolate, containing reference to :id, :style
and :extension.
Because of his postion order in the array, only :extension will be
correctly remplaced, not :style and :id
This come from the files interpolations.rb :
def self.interpolate pattern, *args
all.reverse.inject( pattern.dup ) do |result, tag|
result.gsub(/:#{tag}/) do |match|
send( tag, *args )
end
end
end
So a tips is to rename the reference from :full_path to :zfull_path
and it's work nicely :) A simple patch will be to take care in first
of all personals defined patterns and after of all standard inbuilt
patterns( :id, :style, etc...)
If you want take a look to the complete code, go here :
http://gist.github.com/127725
and watch the paperclip.rb for the interpolate function.
It's a use of paperclip for handling multiples mime type file in one
polymorph table, and abstract all the data. All the processors are
defined on the before_post_process (see the ActiveRecord definition in
wrapper.rb file). (all processors are fully functionals on Vista/Ruby
1.8 with ghoscript and ffmpeg installed)
And this is my second request : as i don't won't to apply processor in
some time, i have build an empty_processor.rb with return a nil value.
So i have modified the flush_write method (in storage.rb) from :
def flush_writes #:nodoc:
@queued_for_write.each do |style, file|
next if file.nil? # <----
line added
file.close if !file.closed? #
<---- line modified
FileUtils.mkdir_p(File.dirname(path(style)))
log("saving #{path(style)}")
FileUtils.mv(file.path, path(style))
FileUtils.chmod(0644, path(style))
end
@queued_for_write = {}
end
The second line "file.close if !file.closed" must be because the
video_convert_processor must close the temp file in order to make a
properly call to ffmpeg (witch can not accept an open file, take a
look at the video_convert_processor.rb file : i close it before the
final process).
Thanks,
--
Traz