Class: Marlens::JiraApi::RemoteImageAttachmentUploader
- Inherits:
-
Object
- Object
- Marlens::JiraApi::RemoteImageAttachmentUploader
- Defined in:
- lib/marlens/jira_api/remote_image_attachment_uploader.rb
Constant Summary collapse
- MAX_REDIRECTS =
5
Instance Method Summary collapse
-
#initialize(client:, issue_key:, allowed_hosts:) ⇒ RemoteImageAttachmentUploader
constructor
A new instance of RemoteImageAttachmentUploader.
- #media_node_for(image) ⇒ Object
Constructor Details
#initialize(client:, issue_key:, allowed_hosts:) ⇒ RemoteImageAttachmentUploader
Returns a new instance of RemoteImageAttachmentUploader.
13 14 15 16 17 |
# File 'lib/marlens/jira_api/remote_image_attachment_uploader.rb', line 13 def initialize(client:, issue_key:, allowed_hosts:) @allowed_hosts = allowed_hosts @client = client @issue_key = issue_key end |
Instance Method Details
#media_node_for(image) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/marlens/jira_api/remote_image_attachment_uploader.rb', line 19 def media_node_for(image) = (image.fetch(:url)) dimensions = .fetch("dimensions") MarkdownToAdf.media_single( id: .fetch("id"), alt: image[:alt].to_s.strip.empty? ? .fetch("filename") : image[:alt], width: image_dimension_value(image[:width], dimensions.fetch("width")), height: image_dimension_value(image[:height], dimensions.fetch("height")) ) rescue StandardError => error warn "Failed to upload image #{image[:url]}: #{error.class}: #{error.}" MarkdownToAdf.paragraph("#{image[:alt] || "Image"}: #{image[:url]}") end |