Class: Frizz::Remote

Inherits:
Object
  • Object
show all
Defined in:
lib/frizz/remote.rb

Instance Method Summary collapse

Constructor Details

#initialize(bucket_name, ignorance, options = {}) ⇒ Remote

Returns a new instance of Remote.



6
7
8
9
10
# File 'lib/frizz/remote.rb', line 6

def initialize(bucket_name, ignorance, options = {})
  @options = options
  @bucket_name = bucket_name
  @ignorance = ignorance
end

Instance Method Details

#delete(remote_file) ⇒ Object



30
31
32
33
34
35
# File 'lib/frizz/remote.rb', line 30

def delete(remote_file)
  client.delete_object(
    bucket: bucket_name,
    key: remote_file.key
  )
end

#filesObject



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

def files
  @files ||= objects.reject { |o| ignore?(o) }
end

#upload(file, key, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/frizz/remote.rb', line 16

def upload(file, key, options = {})
  object_options = {
    bucket: bucket_name,
    body: file,
    acl: 'public-read',
    content_type: MIME::Types.type_for(key).first.content_type,
    key: key
  }

  object_options[:website_redirect_location] = options[:redirect_to] if options[:redirect_to]

  client.put_object object_options
end