Class: Inkcite::Uploader

Inherits:
Object
  • Object
show all
Defined in:
lib/inkcite/uploader.rb

Class Method Summary collapse

Class Method Details

.upload(email) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/inkcite/uploader.rb', line 7

def self.upload email

  times = []

  ['source.html', 'source.txt', 'helpers.tsv'].each do |file|
    file = email.project_file(file)
    times << File.mtime(file).to_i if File.exist?(file)
  end

  local_images = email.image_dir
  if File.exist?(local_images)
    Dir.foreach(local_images) do |file|
      times << File.mtime(File.join(local_images, file)).to_i unless file.starts_with?('.')
    end
  end

  # Get the most recently updated file.
  last_update = times.max

  # Determine when the last upload was completed.
  last_upload = email.meta(:last_upload).to_i

  self.do_upload(email, false) if last_update > last_upload

end

.upload!(email) ⇒ Object



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

def self.upload! email
  self.do_upload(email, true)
end