Class: UploadManager
- Inherits:
-
Object
- Object
- UploadManager
- Defined in:
- lib/second_curtain/upload_manager.rb
Instance Method Summary collapse
- #enqueue_upload(expected_path, actual_path) ⇒ Object
-
#initialize(bucket, path_prefix) ⇒ UploadManager
constructor
A new instance of UploadManager.
- #upload(folder_name) ⇒ Object
Constructor Details
#initialize(bucket, path_prefix) ⇒ UploadManager
Returns a new instance of UploadManager.
6 7 8 9 10 11 12 13 |
# File 'lib/second_curtain/upload_manager.rb', line 6 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 |
Instance Method Details
#enqueue_upload(expected_path, actual_path) ⇒ Object
15 16 17 |
# File 'lib/second_curtain/upload_manager.rb', line 15 def enqueue_upload(expected_path, actual_path) @uploads.push(Upload.new(expected_path, actual_path)) end |
#upload(folder_name) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/second_curtain/upload_manager.rb', line 19 def upload(folder_name) return nil unless @uploads.count > 0 @uploads.each do |upload| upload.upload(@bucket, @path_prefix) end preview = WebPreview.new(@uploads) index_object = @bucket.objects[@path_prefix + folder_name + "/index.html"] index_object.write(preview.generate_html) index_object.public_url.to_s end |