Module: Defile

Defined in:
lib/defile.rb,
lib/defile/app.rb,
lib/defile/file.rb,
lib/defile/rails.rb,
lib/defile/version.rb,
lib/defile/attachment.rb,
lib/defile/backend/s3.rb,
lib/defile/image_processing.rb,
lib/defile/backend/file_system.rb,
lib/defile/attachment/active_record.rb

Defined Under Namespace

Modules: ActiveRecord, Attachment, AttachmentFieldHelper, Backend, Controller Classes: App, Engine, File, ImageProcessor, Invalid, RandomHasher

Constant Summary collapse

VERSION =
"0.2.1"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.appObject

Returns the value of attribute app.



9
10
11
# File 'lib/defile.rb', line 9

def app
  @app
end

.cacheObject



33
34
35
# File 'lib/defile.rb', line 33

def cache
  backends["cache"]
end

.direct_uploadObject

Returns the value of attribute direct_upload.



9
10
11
# File 'lib/defile.rb', line 9

def direct_upload
  @direct_upload
end

.hostObject

Returns the value of attribute host.



9
10
11
# File 'lib/defile.rb', line 9

def host
  @host
end

.read_chunk_sizeObject

Returns the value of attribute read_chunk_size.



9
10
11
# File 'lib/defile.rb', line 9

def read_chunk_size
  @read_chunk_size
end

.storeObject



25
26
27
# File 'lib/defile.rb', line 25

def store
  backends["store"]
end

Class Method Details

.backendsObject



12
13
14
# File 'lib/defile.rb', line 12

def backends
  @backends ||= {}
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Defile)

    the object that the method was called on



41
42
43
# File 'lib/defile.rb', line 41

def configure
  yield self
end

.processor(name, processor = nil, &block) ⇒ Object



20
21
22
23
# File 'lib/defile.rb', line 20

def processor(name, processor = nil, &block)
  processor ||= block
  processors[name.to_s] = processor
end

.processorsObject



16
17
18
# File 'lib/defile.rb', line 16

def processors
  @processors ||= {}
end

.verify_uploadable(uploadable, max_size) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/defile.rb', line 45

def verify_uploadable(uploadable, max_size)
  [:size, :read, :eof?, :close].each do |m|
    unless uploadable.respond_to?(m)
      raise ArgumentError, "does not respond to `#{m}`."
    end
  end
  if max_size and uploadable.size > max_size
    raise Defile::Invalid, "#{uploadable.inspect} is too large"
  end
  true
end