lib/attachs/storages/local.rb in attachs-0.4.0 vs lib/attachs/storages/local.rb in attachs-0.4.1
- old
+ new
@@ -2,11 +2,11 @@
module Storages
class Local < Base
def url(style=:original)
if attachment.url?
- base_url.join(path(style)).to_s
+ "#{base_url.join(path(style))}?#{attachment.updated_at.to_i}"
end
end
def process(force=false)
if attachment.upload?
@@ -22,18 +22,21 @@
process_styles force
end
def process_styles(force=false)
if attachment.image?
- attachment.styles.each do |style|
- if force == true
- delete realpath(style)
+ attachment.processors.each do |klass|
+ processor = klass.new(attachment, realpath)
+ attachment.styles.each do |style|
+ if force == true
+ delete realpath(style)
+ end
+ unless File.exist? realpath(style)
+ FileUtils.mkdir_p realpath(style).dirname
+ processor.process style, realpath(style)
+ end
end
- unless File.exist? realpath(style)
- FileUtils.mkdir_p realpath(style).dirname
- resize realpath, style, realpath(style)
- end
end
end
end
def destroy
@@ -48,13 +51,9 @@
end
end
end
protected
-
- def move(origin, destination)
- FileUtils.mv base_path.join(origin), base_path.join(destination)
- end
def delete(realpath)
if File.exist? realpath
File.delete realpath
end