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, #matching_etag?

Methods included from Mixins::LogHelper

#class_name

Instance Method Details

#bodyObject



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

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

#determine_content_lengthObject



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

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

#determine_content_typeObject



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

def determine_content_type
  MultiMime.type_for_path(path_with_root.to_s)
end

#determine_etagObject



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

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

#determine_mtimeObject



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

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