class UploadManager

Public Class Methods

new(bucket, path_prefix) click to toggle source
# File lib/upload_manager.rb, line 5
def initialize (bucket, path_prefix)
        abort "error: must supply an S3 bucket" unless bucket
        abort "error: must supply a path prefix of at least '/'" unless path_prefix

        @uploads = []
        @path_prefix = path_prefix
        @bucket = bucket
end

Public Instance Methods

enqueue_upload(expected_path, actual_path) click to toggle source
# File lib/upload_manager.rb, line 14
def enqueue_upload(expected_path, actual_path)
        @uploads.push(Upload.new(expected_path, actual_path))
end
to_html() click to toggle source
# File lib/upload_manager.rb, line 30
def to_html
        "<html><body>#{@uploads.map(&:to_html).join}</body></html>"
end
upload(folder_name) click to toggle source
# File lib/upload_manager.rb, line 18
def upload(folder_name)
        return nil unless @uploads.count > 0

        @uploads.each do |upload|
                upload.upload(@bucket, @path_prefix)
        end

        index_object = @bucket.objects[@path_prefix + folder_name + "/index.html"]
        index_object.write(to_html)
        index_object.url_for(:read).to_s
end