opossum 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 721a81517304c17e172662c5fbd1e055dd3d218658749d04efd02191cb866eb6
4
- data.tar.gz: 006cdb6681a963740d03d62dd566f2a3323027556dacc8591afc6c3e8732fcc6
3
+ metadata.gz: df8e444fc778cd27c93ecb9883823ab6efb78ca246de662197c541c07d09b374
4
+ data.tar.gz: 464802dcd3a9a0451ad5a91c6d742e84c74e3be304e23dac96b6300a7c0faf59
5
5
  SHA512:
6
- metadata.gz: 23a6aa7fe4861ca4c62eb3a293fe4d507c2b33d479253b1340cddf561f97a43827170fa29d4b7a8f3db2b72fc739a3423fea49645d88ede37f0b443e5fd47170
7
- data.tar.gz: 7ce15a3f0382aa0b57671c6aa62fc53f1dec2c214e52a90bfec640f2ef2d8fb209d64d42c26abc5f28d2bbc01090979f6ca25136078e0d6a3772fd55ba3402cb
6
+ metadata.gz: 4002dbb64d04fee6b4e59b97f597c9ddc627b03952f7e8bc9330cab6895d217e345e34047a7251e7336453e39e0e38e29ab5e348ca12e91945390338e420d221
7
+ data.tar.gz: 4047063fac5fd46c4fb3edeb450fc81c6c13bbbf3712a50088ad66d90b7f7a36768e33d44aafe9dcc9c5630e38a80f62e8e48c8be51b32297bb0d8a8a890dbf1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.5.0] - 2026-10-12
2
+
3
+ ### Added
4
+ - **Alt text** - `Publisher#publish_media` accepts `alt_text:`
5
+ - A `String` for a single image, or an `Array` parallel to `media_url` for a carousel
6
+ - Sent as `alt_text` on `IMAGE` containers only (Instagram does not support it on videos, reels or stories); blank values are omitted
7
+
1
8
  ## [0.4.0] - 2026-10-06
2
9
 
3
10
  ### Added
data/README.md CHANGED
@@ -121,6 +121,20 @@ result = publisher.publish_media(
121
121
  caption: 'Photo collection from my trip ✈️ #travel #memories'
122
122
  )
123
123
 
124
+ # Publish image with alt text (accessibility; images only)
125
+ result = publisher.publish_media(
126
+ media_url: 'https://example.com/image.jpg',
127
+ media_type: 'IMAGE',
128
+ alt_text: 'Team photo at the rally'
129
+ )
130
+
131
+ # Publish carousel with per-image alt text (array parallel to media_url, nil to skip one)
132
+ result = publisher.publish_media(
133
+ media_url: ['https://example.com/image1.jpg', 'https://example.com/image2.jpg'],
134
+ media_type: 'CAROUSEL',
135
+ alt_text: ['Team photo at the rally', nil]
136
+ )
137
+
124
138
  # Publish a story (media_format picks image_url vs video_url; default is VIDEO)
125
139
  result = publisher.publish_media(
126
140
  media_url: 'https://example.com/story.jpg',
@@ -14,10 +14,14 @@ module Opossum
14
14
 
15
15
  # media_format applies to STORIES only: "IMAGE" sends the url as image_url,
16
16
  # "VIDEO" (the default) as video_url. Other media types ignore it.
17
- def publish_media(media_url:, media_type: "IMAGE", caption: nil, media_format: nil)
17
+ #
18
+ # alt_text is sent only for image containers (Instagram ignores it on
19
+ # videos, reels and stories): a String for a single image, or an Array
20
+ # parallel to media_url for a carousel (nil entries are skipped).
21
+ def publish_media(media_url:, media_type: "IMAGE", caption: nil, media_format: nil, alt_text: nil)
18
22
  path = "#{INSTAGRAM_GRAPH_API_ENDPOINT}/#{GRAPH_API_VERSION}/#{ig_id}/media_publish"
19
23
  media_container_id = prepare_media_container(media_url: media_url, media_type: media_type, caption: caption,
20
- media_format: media_format)
24
+ media_format: media_format, alt_text: alt_text)
21
25
 
22
26
  ApiHelper.post(
23
27
  path: path,
@@ -29,19 +33,20 @@ module Opossum
29
33
 
30
34
  attr_reader :ig_id
31
35
 
32
- def prepare_media_container(media_url:, media_type:, caption:, media_format: nil)
36
+ def prepare_media_container(media_url:, media_type:, caption:, media_format: nil, alt_text: nil)
33
37
  if media_url.is_a?(Array)
34
- prepare_carousel_media(media_urls: media_url, media_type: media_type, caption: caption)
38
+ prepare_carousel_media(media_urls: media_url, media_type: media_type, caption: caption,
39
+ alt_texts: Array(alt_text))
35
40
  else
36
41
  create_media_container(media_url: media_url, media_type: media_type, caption: caption,
37
- media_format: media_format)
42
+ media_format: media_format, alt_text: alt_text)
38
43
  end
39
44
  end
40
45
 
41
- def prepare_carousel_media(media_urls:, media_type:, caption:)
42
- threads = media_urls.map do |url|
46
+ def prepare_carousel_media(media_urls:, media_type:, caption:, alt_texts: [])
47
+ threads = media_urls.each_with_index.map do |url, index|
43
48
  Thread.new do
44
- create_media_container(media_url: url, is_carousel_item: true, caption: caption)
49
+ create_media_container(media_url: url, is_carousel_item: true, caption: caption, alt_text: alt_texts[index])
45
50
  end
46
51
  end
47
52
 
@@ -50,7 +55,7 @@ module Opossum
50
55
  create_media_container(media_url: children_ids, media_type: media_type, caption: caption)
51
56
  end
52
57
 
53
- # options: is_carousel_item:, upload_type:, media_format:
58
+ # options: is_carousel_item:, upload_type:, media_format:, alt_text:
54
59
  def create_media_container(media_url:, media_type: "IMAGE", caption: nil, **options)
55
60
  path = "#{INSTAGRAM_GRAPH_API_ENDPOINT}/#{GRAPH_API_VERSION}/#{ig_id}/media"
56
61
  body = build_media_container_body(media_url: media_url, media_type: media_type, caption: caption, **options)
@@ -67,9 +72,14 @@ module Opossum
67
72
  set_media_url_field(body, media_url, media_type, options[:media_format])
68
73
  body[:is_carousel_item] = options[:is_carousel_item] if options[:is_carousel_item]
69
74
  body[:upload_type] = options[:upload_type] if options[:upload_type]
75
+ body[:alt_text] = options[:alt_text] if alt_text_applicable?(media_type, options[:alt_text])
70
76
  body
71
77
  end
72
78
 
79
+ def alt_text_applicable?(media_type, alt_text)
80
+ media_type == "IMAGE" && !alt_text.nil? && !alt_text.to_s.strip.empty?
81
+ end
82
+
73
83
  def set_media_url_field(body, media_url, media_type, media_format = nil)
74
84
  case media_type
75
85
  when "IMAGE"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Opossum
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opossum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vadym Kruchyna
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-10-06 00:00:00.000000000 Z
11
+ date: 2026-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday