Seamus¶ ↑
Seamus is not an Irish monk. Instead, it inspects a file and returns whatever metadata it can determine.
Usage¶ ↑
Seamus inspects your file and discovers useful attributes. It is at its best with rich digital media - video, audio and image files - but is suitable for use with any file type. Just provide a path to Seamus::Builder.new for an enhanced File object that knows about your file.
movie = Seamus::Builder.new("/path/to/my/movie.mov") movie.width # => 720 movie.video_codec # => 'h264'
Or if you prefer, include Seamus in a class and use the has_file :file_attribute class method for attachments.
class Upload include Seamus has_file :file end u = Upload.new u.file = "/path/to/image.jpg" u.file.width # => 3284
Seamus supports thumbnail creation for visual media types. The #thumbnail method returns an IO instance.
u.file.thumbnail # => #<IO:0x357898>
Extending Seamus¶ ↑
Seamus dynamically generates classes for file types as it encounters them. Seamus::Builder will, for example, generate a Seamus::File::Mp4 class and instance when given a path to an MPEG-4 file with .mp4 extension, which subclasses Seamus::File::Video.
You can build custom behavior around a file type by defining a class Seamus::File::<extname> that either subclasses File, subclasses one of Seamus::File’s template classes, or implements a path handler of some kind.
Note on Patches/Pull Requests¶ ↑
-
I’d be very surprised if anyone wanted to do such a thing. But if you really do, contact me and we’ll work something out.
Copyright¶ ↑
Copyright © 2010 Scott Burton. See LICENSE for details.