Derivate blocks are executed in context of the uploader instance:
class ImageUploader < Shrine
plugin :derivate_endpoint
derivate :thumbnail do |file, context|| require "sequel" | |
| require "shrine" | |
| require "shrine/storage/memory" | |
| require "zip" | |
| require "tempfile" | |
| require "securerandom" | |
| DB = Sequel.sqlite | |
| DB.create_table :archives do | |
| primary_key :id |
| require "mongoid" | |
| require "shrine" | |
| require "shrine/storage/memory" | |
| require "stringio" | |
| Mongoid.configure do |config| | |
| config.clients.default = { hosts: ['localhost:27017'], database: 'my_db' } | |
| config.log_level = :debug | |
| end |
| require "sequel" | |
| require "benchmark" | |
| system "createdb testing" | |
| DB = Sequel.postgres("testing") | |
| at_exit do | |
| DB.disconnect | |
| system "dropdb testing" | |
| end |
| source "https://rubygems.org" | |
| gem "roda" | |
| gem "http", "~> 3.3" | |
| gem "rest-client" | |
| gem "httparty" |
| class Shrine | |
| module Plugins | |
| # The `concatenation` plugin allows you to assign to the attacher a | |
| # cached file which is composed of multiple uploaded parts. The plugin | |
| # will then call `#concat` on the storage, which is expected to | |
| # concatenate the given parts into a single file. The assigned | |
| # attachment will then be a complete cached file. | |
| # | |
| # plugin :concatenation | |
| # |
| source "https://rubygems.org" | |
| gem "shrine", github: "janko-m/shrine" | |
| gem "rom-repository" | |
| gem "rom-sql" | |
| gem "sqlite3" | |
| gem "dry-validation" | |
| gem "roda" | |
| gem "sucker_punch", "~> 2.0" |