Created
January 24, 2012 01:44
-
-
Save codatory/1667259 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExifData | |
require 'celluloid' | |
def initialize(file) | |
raise 'Expects Upload!' unless file.is_a?(Upload) | |
@upload = file | |
end | |
def process! | |
# this is fictitional | |
@exif_data ||= ActiveExif::new(@upload.read).process.to_hash | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MagickData | |
require 'celluloid' | |
def initialize(file) | |
raise 'Expects Upload!' unless file.is_a?(Upload) | |
@upload = file | |
end | |
def process! | |
# this is fictitional | |
@exif_data ||= ActiveMagick::new(@upload.read).process.to_hash | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Upload | |
def initialize(file) | |
@file = File.open(file) | |
end | |
def read | |
@image ||= @file.read | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upload = Upload.new('/tmp/file.jpg') | |
# WILL NOT block | |
exif_data = ExifData.new(upload).future :process! | |
magick_data = MagickData.new(upload).future :process! | |
# WILL block | |
data = exif_data.value + magick_data.value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment