class UploadManager
Public Class Methods
new(bucket, path_prefix)
click to toggle source
# File lib/second_curtain/upload_manager.rb, line 7 def initialize (bucket, path_prefix) abort "error: Second Curtain must supply an S3 bucket" unless bucket abort "error: Second Curtain 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/second_curtain/upload_manager.rb, line 16 def enqueue_upload(expected_path, actual_path) @uploads.push(Upload.new(expected_path, actual_path)) end
upload(folder_name)
click to toggle source
# File lib/second_curtain/upload_manager.rb, line 20 def upload(folder_name) return nil unless @uploads.count > 0 @uploads.each do |upload| upload.upload(@bucket, PathUtils.pathWithComponents([@path_prefix, folder_name])) end preview = WebPreview.new(@uploads) index_object = @bucket.objects[PathUtils.pathWithComponents([@path_prefix, folder_name, "index.html"])] index_object.write(preview.generate_html) index_object.public_url.to_s end