Module: PictureHandler::Uploader::MiniMagick::ClassMethods
- Defined in:
- lib/picture_handler/uploader/mini_magick.rb
Overview
Common method for all file_system
Instance Method Summary collapse
- #create_directories_for_path(dir_tokens) ⇒ Object
-
#open_source(source_path) ⇒ Object
Open the source File/path/ or URL, raise an error if blank.
-
#split_dirname_path(some_path) ⇒ Object
Works for Windows C:Filesetc or Linux /usr/app/etc.
Instance Method Details
#create_directories_for_path(dir_tokens) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/picture_handler/uploader/mini_magick.rb', line 31 def create_directories_for_path(dir_tokens) 1.upto(dir_tokens.size) do |n| dir = dir_tokens[0...n] dir_str = dir.join("/") Dir.mkdir(dir_str) unless Dir.exist?(dir_str) end end |
#open_source(source_path) ⇒ Object
Open the source File/path/ or URL, raise an error if blank
21 22 23 24 25 26 27 28 29 |
# File 'lib/picture_handler/uploader/mini_magick.rb', line 21 def open_source(source_path) raise PictureHandler::Exceptions::OpenError.new("nil") if source_path.blank? image = ::MiniMagick::Image.open(source_path) if image.blank? raise PictureHandler::Exceptions::OpenError.new(source_path) end image end |
#split_dirname_path(some_path) ⇒ Object
Works for Windows C:Filesetc or Linux /usr/app/etc
40 41 42 43 44 |
# File 'lib/picture_handler/uploader/mini_magick.rb', line 40 def split_dirname_path(some_path) dirname = File.dirname(some_path) tokens = dirname.split(/[\/\\]/) tokens end |