Class: MultiSync::LocalResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/multi_sync/resources/local_resource.rb

Constant Summary

Constants inherited from Resource

Resource::AWS_ATTRIBUTES

Instance Method Summary collapse

Methods inherited from Resource

#<=>, #==, #hash, #initialize, #matching_etag?

Constructor Details

This class inherits a constructor from MultiSync::Resource

Instance Method Details

#bodyObject



6
7
8
9
10
# File 'lib/multi_sync/resources/local_resource.rb', line 6

def body
  File.read(path_with_root.to_s)
rescue
  return nil
end

#determine_content_lengthObject



26
27
28
# File 'lib/multi_sync/resources/local_resource.rb', line 26

def determine_content_length
  body.nil? ? 0 : Fog::Storage.get_body_size(body)
end

#determine_content_typeObject



22
23
24
# File 'lib/multi_sync/resources/local_resource.rb', line 22

def determine_content_type
  MultiMime.type_for_path(path_with_root.to_s)
end

#determine_etagObject



12
13
14
# File 'lib/multi_sync/resources/local_resource.rb', line 12

def determine_etag
  body.nil? ? nil : Digest::MD5.hexdigest(body)
end

#determine_mtimeObject



16
17
18
19
20
# File 'lib/multi_sync/resources/local_resource.rb', line 16

def determine_mtime
  File.mtime(path_with_root.to_s)
rescue
  return nil
end