188
189
190
191
192
193
194
195
196
197
198
199
200
|
# File 'lib/cnvrg/files.rb', line 188
def parse_file(file)
abs_path = "#{@project_home}/#{file}"
return {relative_path: file, absolute_path: abs_path} if file.ends_with? '/'
file_name = File.basename(file)
file_size = File.size abs_path
mime_type = MimeMagic.by_path(abs_path)
content_type = !(mime_type.nil? or mime_type.text?) ? mime_type.type : "text/plain"
sha1 = OpenSSL::Digest::SHA1.file(abs_path).hexdigest
{relative_path: file, absolute_path: abs_path, file_name: file_name, file_size: file_size, content_type: content_type, sha1: sha1}
rescue => e
return false
end
|