Class: Happo::Uploader
- Inherits:
-
Object
- Object
- Happo::Uploader
- Defined in:
- lib/happo/uploader.rb
Overview
Handles uploading diffs (serialized html doc + images) to an Amazon S3 account.
Instance Method Summary collapse
-
#initialize ⇒ Uploader
constructor
A new instance of Uploader.
- #upload_diffs(triggered_by_url) ⇒ Object
Constructor Details
#initialize ⇒ Uploader
Returns a new instance of Uploader.
9 10 11 12 13 14 |
# File 'lib/happo/uploader.rb', line 9 def initialize @s3_access_key_id = ENV['S3_ACCESS_KEY_ID'] @s3_secret_access_key = ENV['S3_SECRET_ACCESS_KEY'] @s3_bucket_name = ENV['S3_BUCKET_NAME'] @s3_bucket_path = ENV['S3_BUCKET_PATH'] end |
Instance Method Details
#upload_diffs(triggered_by_url) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/happo/uploader.rb', line 16 def upload_diffs(triggered_by_url) result_summary = Happo::Utils.last_result_summary return [] if result_summary[:diff_examples].empty? && result_summary[:new_examples].empty? diff_images = result_summary[:diff_examples].map do |example| example[:previous] = upload_image(example, 'previous') example[:current] = upload_image(example, 'current') example end new_images = result_summary[:new_examples].map do |example| example[:current] = upload_image(example, 'current') example end html = build_object('index.html') path = File.( File.join(File.dirname(__FILE__), 'views', 'diffs.erb') ) html.content = ERB.new(File.read(path)).result(binding) html.content_encoding = 'utf-8' html.content_type = 'text/html' html.save html.url end |