Sha256: d647645967c1012de9f0f4f36bc1188dc19f8ecf88dd024fbea589a0804c6985
Contents?: true
Size: 1.7 KB
Versions: 1
Compression:
Stored size: 1.7 KB
Contents
Analysers ========= Analysers are registered with Dragonfly apps for adding methods to {file:GeneralUsage Job} objects and {file:Models model attachments} such as `width`, `height`, etc. ImageMagick Analyser -------------------- See {file:ImageMagick}. FileCommandAnalyser ------------------- The {Dragonfly::Analysis::FileCommandAnalyser FileCommandAnalyser} is registered by default by the {Dragonfly::Config::Rails Rails configuration} used by 'dragonfly/rails/images'. As the name suggests, it uses the UNIX 'file' command. If not already registered: app.analyser.register(Dragonfly::Analysis::FileCommandAnalyser) gives us: image.mime_type # => 'image/png' It doesn't use the filesystem by default (it operates on in-memory strings), but we can make it do so by using app.analyser.register(Dragonfly::Analysis::FileCommandAnalyser) do |a| a.use_filesystem = true end Custom Analysers ---------------- To register a single custom analyser: app.analyser.add :wobbliness do |temp_object| # can use temp_object.data, temp_object.path, temp_object.file, etc. SomeLibrary.assess_wobbliness(temp_object.data) end image.wobbliness # => 71 You can create a class like the ImageMagick one above, in which case all public methods will be counted as analysis methods. Each method takes the temp_object as its argument. class MyAnalyser def coolness(temp_object) temp_object.size / 30 end def uglyness(temp_object) `ugly -i #{temp_object.path}` end private def my_helper_method # do stuff end end app.analyser.register(MyAnalyser) image.coolness # => -4.1 image.uglyness # => "VERY"
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
oahu-dragonfly-0.8.2 | extra_docs/Analysers.md |