Sha256: c5a34a01243ebc1557a93466b1af8306e499db2718cfd9db04cc41341fa32abb
Contents?: true
Size: 1.27 KB
Versions: 2
Compression:
Stored size: 1.27 KB
Contents
# encoding: utf-8 module TBird class Uploader attr_reader :file, :options, :uploads, :content_type, :original_filename, :metadata def initialize(file, options = {}) @file = file @options = default_options.merge(options) @uploads = {} @content_type = @file[:type] @original_filename = @file[:filename] @metadata = { content_type: content_type, metadata: @options[:metadata] || {} } end def namer @namer ||= Namer.new(original_filename, options[:identifier], options[:token]) end def processor Processor.new(@file[:tempfile]) end def transmitter @transmitter ||= Transmitter.new end def upload! versions.each do |version,block| @uploads[version] = transmitter.transmit!(namer.new_name(version), block.call(processor), metadata) end uploads end def versions self.class.versions end def self.versions @versions ||= { thumbnail: ->(img) { img.thumbnail }, original: ->(img) { img.original } } end def self.version(name, &block) @versions ||= {} @versions[name.to_sym] = block end private def default_options { identifier: nil, token: nil } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
t_bird-0.0.4 | lib/t_bird/uploader.rb |
t_bird-0.0.3 | lib/t_bird/uploader.rb |