shep 0.2.0.pre.alpha0 → 0.2.1.pre.alpha0

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: a56bfae621da4224d6bd267c8c3fc58b7093c4b3f84ae7ebdfa86abbe554dbce
4
- data.tar.gz: 95f03c1f3e0d433d7fbabce22dbffbfe004e50d23d134b9b7cab247fa91e014d
3
+ metadata.gz: 8f4a9bca801cc45d91592b3d31f76806ac672e7357cd49dfafc179152a87471f
4
+ data.tar.gz: aed06e61da3fff93695852f8236380e7be5fb22b046be0355705eb259a2cd50d
5
5
  SHA512:
6
- metadata.gz: f6218ffa77946ebf9681ca881ec33e514693c4d0ee19216eafcb57fef748cdaf03785837520c6dc925ed2e9ff857f1f84dd5eb0a95e84d0a99938e3890b9b6ef
7
- data.tar.gz: d8cfd8503e4b3e5acdda990c17dc3181060436d702ddc19e01bef0d2c18147d0330b4649e67df7028c5d84085376b0ccb38002bea34d7ae8ff14625f3a763218
6
+ metadata.gz: 1006f24313ec50a7c53e93d74af104e239504411d44b1cee0fe440e09042bea6eb6e80de80545c0332810baf50c1c5291bdf84b3f935e141323b4de745c26ab5
7
+ data.tar.gz: 89bb2df74de07fc6c21173aa93209414c582fd356562c91b8f712122b2824ffd53f362d0d462736c668bb6ae5fa48199036869485a763f99b93feccef693f181
@@ -168,7 +168,7 @@
168
168
  </div>
169
169
 
170
170
  <div id="footer">
171
- Generated on Sat Jun 10 19:16:29 2023 by
171
+ Generated on Thu Jun 15 10:09:20 2023 by
172
172
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
173
173
  0.9.34 (ruby-3.0.3).
174
174
  </div>
@@ -106,8 +106,8 @@
106
106
  <p>Ruby object representing a Mastodon <code>Context</code> object:</p>
107
107
 
108
108
  <ul>
109
- <li>ancestors (Array<a href="Entity::Status">Entity::Status</a>)</li>
110
- <li>descendants (Array<a href="Entity::Status">Entity::Status</a>)</li>
109
+ <li>ancestors (Array&lt;<span class='object_link'><a href="Status.html" title="Shep::Entity::Status (class)">Status</a></span>&gt;)</li>
110
+ <li>descendants (Array&lt;<span class='object_link'><a href="Status.html" title="Shep::Entity::Status (class)">Status</a></span>&gt;)</li>
111
111
  </ul>
112
112
 
113
113
  <p>See <code>Shep::Entity</code> for an overview.</p>
@@ -154,7 +154,7 @@
154
154
  </div>
155
155
 
156
156
  <div id="footer">
157
- Generated on Sat Jun 10 19:16:29 2023 by
157
+ Generated on Thu Jun 15 10:09:20 2023 by
158
158
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
159
159
  0.9.34 (ruby-3.0.3).
160
160
  </div>
@@ -157,7 +157,7 @@
157
157
  </div>
158
158
 
159
159
  <div id="footer">
160
- Generated on Sat Jun 10 19:16:29 2023 by
160
+ Generated on Thu Jun 15 10:09:20 2023 by
161
161
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
162
162
  0.9.34 (ruby-3.0.3).
163
163
  </div>
@@ -159,7 +159,7 @@
159
159
  </div>
160
160
 
161
161
  <div id="footer">
162
- Generated on Sat Jun 10 19:16:29 2023 by
162
+ Generated on Thu Jun 15 10:09:20 2023 by
163
163
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
164
164
  0.9.34 (ruby-3.0.3).
165
165
  </div>
@@ -109,8 +109,8 @@
109
109
  <li>id (String)</li>
110
110
  <li>type (String)</li>
111
111
  <li>created_at (Time)</li>
112
- <li>account (Entity::Account)</li>
113
- <li>status (Entity::Status)</li>
112
+ <li>account (<span class='object_link'><a href="Account.html" title="Shep::Entity::Account (class)">Account</a></span>)</li>
113
+ <li>status (<span class='object_link'><a href="Status.html" title="Shep::Entity::Status (class)">Status</a></span>)</li>
114
114
  </ul>
115
115
 
116
116
  <p>See <code>Shep::Entity</code> for an overview.</p>
@@ -157,7 +157,7 @@
157
157
  </div>
158
158
 
159
159
  <div id="footer">
160
- Generated on Sat Jun 10 19:16:29 2023 by
160
+ Generated on Thu Jun 15 10:09:20 2023 by
161
161
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
162
162
  0.9.34 (ruby-3.0.3).
163
163
  </div>
@@ -109,23 +109,23 @@
109
109
  <li>id (String)</li>
110
110
  <li>uri (URI)</li>
111
111
  <li>created_at (Time)</li>
112
- <li>account (Entity::Account)</li>
112
+ <li>account (<span class='object_link'><a href="Account.html" title="Shep::Entity::Account (class)">Account</a></span>)</li>
113
113
  <li>content (String)</li>
114
114
  <li>visibility (String)</li>
115
115
  <li>sensitive (Boolean)</li>
116
116
  <li>spoiler_text (String)</li>
117
- <li>media_attachments (Array<a href="Entity::MediaAttachment">Entity::MediaAttachment</a>)</li>
118
- <li>applications (Entity::Status_Application)</li>
119
- <li>mentions (Array<a href="Entity::Status_Mention">Entity::Status_Mention</a>)</li>
120
- <li>tags (Array<a href="Entity::Status_Tag">Entity::Status_Tag</a>)</li>
121
- <li>emojis (Array<a href="Entity::CustomEmoji">Entity::CustomEmoji</a>)</li>
117
+ <li>media_attachments (Array&lt;<span class='object_link'><a href="MediaAttachment.html" title="Shep::Entity::MediaAttachment (class)">MediaAttachment</a></span>&gt;)</li>
118
+ <li>applications (<span class='object_link'><a href="Status_Application.html" title="Shep::Entity::Status_Application (class)">Status_Application</a></span>)</li>
119
+ <li>mentions (Array&lt;<span class='object_link'><a href="Status_Mention.html" title="Shep::Entity::Status_Mention (class)">Status_Mention</a></span>&gt;)</li>
120
+ <li>tags (Array&lt;<span class='object_link'><a href="Status_Tag.html" title="Shep::Entity::Status_Tag (class)">Status_Tag</a></span>&gt;)</li>
121
+ <li>emojis (Array&lt;<span class='object_link'><a href="CustomEmoji.html" title="Shep::Entity::CustomEmoji (class)">CustomEmoji</a></span>&gt;)</li>
122
122
  <li>reblogs_count (Integer)</li>
123
123
  <li>favourites_count (Integer)</li>
124
124
  <li>replies_count (Integer)</li>
125
125
  <li>url (URI)</li>
126
126
  <li>in_reply_to_id (String)</li>
127
127
  <li>in_reply_to_account_id (String)</li>
128
- <li>reblog (Entity::Status)</li>
128
+ <li>reblog (<span class='object_link'><a href="" title="Shep::Entity::Status (class)">Status</a></span>)</li>
129
129
  <li>language (String)</li>
130
130
  <li>text (String)</li>
131
131
  <li>edited_at (Time)</li>
@@ -180,7 +180,7 @@
180
180
  </div>
181
181
 
182
182
  <div id="footer">
183
- Generated on Sat Jun 10 19:16:29 2023 by
183
+ Generated on Thu Jun 15 10:09:20 2023 by
184
184
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
185
185
  0.9.34 (ruby-3.0.3).
186
186
  </div>
@@ -155,7 +155,7 @@
155
155
  </div>
156
156
 
157
157
  <div id="footer">
158
- Generated on Sat Jun 10 19:16:29 2023 by
158
+ Generated on Thu Jun 15 10:09:20 2023 by
159
159
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
160
160
  0.9.34 (ruby-3.0.3).
161
161
  </div>
@@ -158,7 +158,7 @@ you the expected fields.</p>
158
158
  </div>
159
159
 
160
160
  <div id="footer">
161
- Generated on Sat Jun 10 19:16:29 2023 by
161
+ Generated on Thu Jun 15 10:09:20 2023 by
162
162
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
163
163
  0.9.34 (ruby-3.0.3).
164
164
  </div>
@@ -156,7 +156,7 @@
156
156
  </div>
157
157
 
158
158
  <div id="footer">
159
- Generated on Sat Jun 10 19:16:29 2023 by
159
+ Generated on Thu Jun 15 10:09:20 2023 by
160
160
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
161
161
  0.9.34 (ruby-3.0.3).
162
162
  </div>
@@ -154,7 +154,7 @@
154
154
  </div>
155
155
 
156
156
  <div id="footer">
157
- Generated on Sat Jun 10 19:16:29 2023 by
157
+ Generated on Thu Jun 15 10:09:20 2023 by
158
158
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
159
159
  0.9.34 (ruby-3.0.3).
160
160
  </div>
data/doc/Shep/Entity.html CHANGED
@@ -1462,7 +1462,7 @@ easily convertable to Mastodon-format JSON. See above.</p>
1462
1462
  </div>
1463
1463
 
1464
1464
  <div id="footer">
1465
- Generated on Sat Jun 10 19:16:29 2023 by
1465
+ Generated on Thu Jun 15 10:09:20 2023 by
1466
1466
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1467
1467
  0.9.34 (ruby-3.0.3).
1468
1468
  </div>
@@ -137,7 +137,7 @@ as incorrect input data (usually)</p>
137
137
  </div>
138
138
 
139
139
  <div id="footer">
140
- Generated on Sat Jun 10 19:16:28 2023 by
140
+ Generated on Thu Jun 15 10:09:19 2023 by
141
141
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
142
142
  0.9.34 (ruby-3.0.3).
143
143
  </div>
@@ -239,18 +239,18 @@ the response object for your perusal.</p>
239
239
  <pre class="lines">
240
240
 
241
241
 
242
- 40
243
- 41
244
- 42
245
242
  43
246
243
  44
247
244
  45
248
245
  46
249
246
  47
250
- 48</pre>
247
+ 48
248
+ 49
249
+ 50
250
+ 51</pre>
251
251
  </td>
252
252
  <td>
253
- <pre class="code"><span class="info file"># File 'lib/shep/exceptions.rb', line 40</span>
253
+ <pre class="code"><span class="info file"># File 'lib/shep/exceptions.rb', line 43</span>
254
254
 
255
255
  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span>
256
256
  <span class='id identifier rubyid_msg'>msg</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>HTTP Error </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
@@ -298,12 +298,12 @@ the response object for your perusal.</p>
298
298
  <pre class="lines">
299
299
 
300
300
 
301
- 39
302
- 40
303
- 41</pre>
301
+ 42
302
+ 43
303
+ 44</pre>
304
304
  </td>
305
305
  <td>
306
- <pre class="code"><span class="info file"># File 'lib/shep/exceptions.rb', line 39</span>
306
+ <pre class="code"><span class="info file"># File 'lib/shep/exceptions.rb', line 42</span>
307
307
 
308
308
  <span class='kw'>def</span> <span class='id identifier rubyid_response'>response</span>
309
309
  <span class='ivar'>@response</span>
@@ -319,7 +319,7 @@ the response object for your perusal.</p>
319
319
  </div>
320
320
 
321
321
  <div id="footer">
322
- Generated on Sat Jun 10 19:16:28 2023 by
322
+ Generated on Thu Jun 15 10:09:20 2023 by
323
323
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
324
324
  0.9.34 (ruby-3.0.3).
325
325
  </div>
@@ -166,7 +166,7 @@ correct reset time, but no promises at this time.</p>
166
166
  </div>
167
167
 
168
168
  <div id="footer">
169
- Generated on Sat Jun 10 19:16:28 2023 by
169
+ Generated on Thu Jun 15 10:09:20 2023 by
170
170
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
171
171
  0.9.34 (ruby-3.0.3).
172
172
  </div>
@@ -132,7 +132,7 @@
132
132
  </div>
133
133
 
134
134
  <div id="footer">
135
- Generated on Sat Jun 10 19:16:28 2023 by
135
+ Generated on Thu Jun 15 10:09:19 2023 by
136
136
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
137
137
  0.9.34 (ruby-3.0.3).
138
138
  </div>
@@ -138,7 +138,7 @@ correctly.)</p>
138
138
  </div>
139
139
 
140
140
  <div id="footer">
141
- Generated on Sat Jun 10 19:16:28 2023 by
141
+ Generated on Thu Jun 15 10:09:19 2023 by
142
142
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
143
143
  0.9.34 (ruby-3.0.3).
144
144
  </div>
@@ -200,12 +200,12 @@
200
200
  <pre class="lines">
201
201
 
202
202
 
203
- 21
204
- 22
205
- 23</pre>
203
+ 24
204
+ 25
205
+ 26</pre>
206
206
  </td>
207
207
  <td>
208
- <pre class="code"><span class="info file"># File 'lib/shep/exceptions.rb', line 21</span>
208
+ <pre class="code"><span class="info file"># File 'lib/shep/exceptions.rb', line 24</span>
209
209
 
210
210
  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_boxdesc'>boxdesc</span><span class='comma'>,</span> <span class='id identifier rubyid_got'>got</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_want'>want</span><span class='rparen'>)</span>
211
211
  <span class='kw'>super</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_boxdesc'>boxdesc</span><span class='embexpr_end'>}</span><span class='tstring_content'> expects </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_want'>want</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>,</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>; got </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_got'>got</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
@@ -221,7 +221,7 @@
221
221
  </div>
222
222
 
223
223
  <div id="footer">
224
- Generated on Sat Jun 10 19:16:28 2023 by
224
+ Generated on Thu Jun 15 10:09:19 2023 by
225
225
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
226
226
  0.9.34 (ruby-3.0.3).
227
227
  </div>
data/doc/Shep/Error.html CHANGED
@@ -106,6 +106,9 @@
106
106
  <p>Base class for exceptions originating from Shep. Use this to trap
107
107
  all Shep exceptions at once.</p>
108
108
 
109
+ <p>Note that Shep usually does not trap exceptions thrown by
110
+ Net::HTTP and friends; you will need to trap those separately.</p>
111
+
109
112
 
110
113
  </div>
111
114
  </div>
@@ -139,7 +142,7 @@ all Shep exceptions at once.</p>
139
142
  </div>
140
143
 
141
144
  <div id="footer">
142
- Generated on Sat Jun 10 19:16:28 2023 by
145
+ Generated on Thu Jun 15 10:09:19 2023 by
143
146
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
144
147
  0.9.34 (ruby-3.0.3).
145
148
  </div>
@@ -820,7 +820,7 @@ so it&#39;s easy to avoid making too many API calls and many have a
820
820
  <li class="public ">
821
821
  <span class="summary_signature">
822
822
 
823
- <a href="#upload_media-instance_method" title="#upload_media (instance method)">#<strong>upload_media</strong>(path, content_type: nil, description: nil, focus_x: nil, focus_y: nil) &#x21d2; Object </a>
823
+ <a href="#upload_media-instance_method" title="#upload_media (instance method)">#<strong>upload_media</strong>(path, content_type: nil, description: nil, focus_x: nil, focus_y: nil) &#x21d2; Entity::MediaAttachment </a>
824
824
 
825
825
 
826
826
 
@@ -1373,10 +1373,10 @@ to reset</p>
1373
1373
  <pre class="lines">
1374
1374
 
1375
1375
 
1376
- 789</pre>
1376
+ 823</pre>
1377
1377
  </td>
1378
1378
  <td>
1379
- <pre class="code"><span class="info file"># File 'lib/shep/session.rb', line 789</span>
1379
+ <pre class="code"><span class="info file"># File 'lib/shep/session.rb', line 823</span>
1380
1380
 
1381
1381
  <span class='kw'>def</span> <span class='id identifier rubyid_delete_status'>delete_status</span><span class='lparen'>(</span><span class='id identifier rubyid_id'>id</span><span class='rparen'>)</span> <span class='op'>=</span> <span class='id identifier rubyid_rest_delete'>rest_delete</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>statuses/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_id'>id</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="Entity.html" title="Shep::Entity (class)">Entity</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Entity/Status.html" title="Shep::Entity::Status (class)">Status</a></span></span><span class='rparen'>)</span></pre>
1382
1382
  </td>
@@ -1420,14 +1420,14 @@ this method.</p>
1420
1420
  <pre class="lines">
1421
1421
 
1422
1422
 
1423
- 798
1424
- 799
1425
- 800
1426
- 801
1427
- 802</pre>
1423
+ 832
1424
+ 833
1425
+ 834
1426
+ 835
1427
+ 836</pre>
1428
1428
  </td>
1429
1429
  <td>
1430
- <pre class="code"><span class="info file"># File 'lib/shep/session.rb', line 798</span>
1430
+ <pre class="code"><span class="info file"># File 'lib/shep/session.rb', line 832</span>
1431
1431
 
1432
1432
  <span class='kw'>def</span> <span class='id identifier rubyid_dismiss_notification'>dismiss_notification</span><span class='lparen'>(</span><span class='id identifier rubyid_id'>id</span><span class='rparen'>)</span>
1433
1433
  <span class='id identifier rubyid_url'>url</span> <span class='op'>=</span> <span class='id identifier rubyid_rest_uri'>rest_uri</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>notifications/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_id'>id</span><span class='embexpr_end'>}</span><span class='tstring_content'>/dismiss</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
@@ -4250,7 +4250,7 @@ latest of these.</p>
4250
4250
  <div class="method_details ">
4251
4251
  <h3 class="signature " id="upload_media-instance_method">
4252
4252
 
4253
- #<strong>upload_media</strong>(path, content_type: nil, description: nil, focus_x: nil, focus_y: nil) &#x21d2; <tt>Object</tt>
4253
+ #<strong>upload_media</strong>(path, content_type: nil, description: nil, focus_x: nil, focus_y: nil) &#x21d2; <tt><span class='object_link'><a href="Entity/MediaAttachment.html" title="Shep::Entity::MediaAttachment (class)">Entity::MediaAttachment</a></span></tt>
4254
4254
 
4255
4255
 
4256
4256
 
@@ -4260,11 +4260,137 @@ latest of these.</p>
4260
4260
  <div class="discussion">
4261
4261
  <p>Upload the media contained in the file at &#39;path&#39;.</p>
4262
4262
 
4263
+ <p>Requires token with sufficient permission for the account that
4264
+ owns the status.</p>
4265
+
4266
+ <p>Note that Mastodon processes attachments asynchronously, so the
4267
+ attachment may not be available for display when this method
4268
+ returns. Posting an unprocessed status as an attachment works
4269
+ as expected but it&#39;s unclear what happens between posting and
4270
+ when the processing task completes. Usually, this shouldn&#39;t
4271
+ matter to you.</p>
4272
+
4273
+ <p>If a rate limit is reached during a call to this method and
4274
+ <code>rate_limit_retry:</code> was set, the media file to upload should not
4275
+ be touched in any way until the method returns.</p>
4276
+
4263
4277
 
4264
4278
  </div>
4265
4279
  </div>
4266
4280
  <div class="tags">
4281
+ <p class="tag_title">Parameters:</p>
4282
+ <ul class="param">
4283
+
4284
+ <li>
4285
+
4286
+ <span class='name'>path</span>
4287
+
4288
+
4289
+ <span class='type'>(<tt>String</tt>)</span>
4290
+
4291
+
4292
+
4293
+ &mdash;
4294
+ <div class='inline'><p>Path to the media file.</p>
4295
+ </div>
4296
+
4297
+ </li>
4298
+
4299
+ <li>
4300
+
4301
+ <span class='name'>content_type</span>
4302
+
4303
+
4304
+ <span class='type'>(<tt>String</tt>)</span>
4305
+
4306
+
4307
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
4308
+
4309
+
4310
+ &mdash;
4311
+ <div class='inline'><p>MIME type of the media attachment.
4312
+ The default us usually all you need.</p>
4313
+ </div>
4314
+
4315
+ </li>
4267
4316
 
4317
+ <li>
4318
+
4319
+ <span class='name'>description</span>
4320
+
4321
+
4322
+ <span class='type'>(<tt>String</tt>)</span>
4323
+
4324
+
4325
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
4326
+
4327
+
4328
+ &mdash;
4329
+ <div class='inline'><p>The image description text.</p>
4330
+ </div>
4331
+
4332
+ </li>
4333
+
4334
+ <li>
4335
+
4336
+ <span class='name'>focus_x</span>
4337
+
4338
+
4339
+ <span class='type'>(<tt>Float</tt>)</span>
4340
+
4341
+
4342
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
4343
+
4344
+
4345
+ &mdash;
4346
+ <div class='inline'><p>The horizontal coordinate of
4347
+ the focus on a range of -1.0
4348
+ to 1.0. This is the point in
4349
+ the image that will be the
4350
+ center of the thumbnail. If
4351
+ set, <code>focus_y:</code> must also be
4352
+ set to a valid coordinate.</p>
4353
+ </div>
4354
+
4355
+ </li>
4356
+
4357
+ <li>
4358
+
4359
+ <span class='name'>focus_y</span>
4360
+
4361
+
4362
+ <span class='type'>(<tt>Float</tt>)</span>
4363
+
4364
+
4365
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
4366
+
4367
+
4368
+ &mdash;
4369
+ <div class='inline'><p>The vertical coordinate of the focus.</p>
4370
+ </div>
4371
+
4372
+ </li>
4373
+
4374
+ </ul>
4375
+
4376
+ <p class="tag_title">Returns:</p>
4377
+ <ul class="return">
4378
+
4379
+ <li>
4380
+
4381
+
4382
+ <span class='type'>(<tt><span class='object_link'><a href="Entity/MediaAttachment.html" title="Shep::Entity::MediaAttachment (class)">Entity::MediaAttachment</a></span></tt>)</span>
4383
+
4384
+
4385
+
4386
+ &mdash;
4387
+ <div class='inline'><p>The resulting MediaAttachment
4388
+ object but without the URL.</p>
4389
+ </div>
4390
+
4391
+ </li>
4392
+
4393
+ </ul>
4268
4394
 
4269
4395
  <p class="tag_title">See Also:</p>
4270
4396
  <ul class="see">
@@ -4279,36 +4405,36 @@ latest of these.</p>
4279
4405
  <pre class="lines">
4280
4406
 
4281
4407
 
4282
- 756
4283
- 757
4284
- 758
4285
- 759
4286
- 760
4287
- 761
4288
- 762
4289
- 763
4290
- 764
4291
- 765
4292
- 766
4293
- 767
4294
- 768
4295
- 769
4296
- 770
4297
- 771
4298
- 772
4299
- 773
4300
- 774
4301
- 775
4302
- 776
4303
- 777
4304
- 778
4305
- 779
4306
- 780
4307
- 781
4308
- 782</pre>
4408
+ 790
4409
+ 791
4410
+ 792
4411
+ 793
4412
+ 794
4413
+ 795
4414
+ 796
4415
+ 797
4416
+ 798
4417
+ 799
4418
+ 800
4419
+ 801
4420
+ 802
4421
+ 803
4422
+ 804
4423
+ 805
4424
+ 806
4425
+ 807
4426
+ 808
4427
+ 809
4428
+ 810
4429
+ 811
4430
+ 812
4431
+ 813
4432
+ 814
4433
+ 815
4434
+ 816</pre>
4309
4435
  </td>
4310
4436
  <td>
4311
- <pre class="code"><span class="info file"># File 'lib/shep/session.rb', line 756</span>
4437
+ <pre class="code"><span class="info file"># File 'lib/shep/session.rb', line 790</span>
4312
4438
 
4313
4439
  <span class='kw'>def</span> <span class='id identifier rubyid_upload_media'>upload_media</span><span class='lparen'>(</span><span class='id identifier rubyid_path'>path</span><span class='comma'>,</span>
4314
4440
  <span class='label'>content_type:</span> <span class='kw'>nil</span><span class='comma'>,</span>
@@ -4409,7 +4535,7 @@ latest of these.</p>
4409
4535
  </div>
4410
4536
 
4411
4537
  <div id="footer">
4412
- Generated on Sat Jun 10 19:16:30 2023 by
4538
+ Generated on Thu Jun 15 10:09:20 2023 by
4413
4539
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
4414
4540
  0.9.34 (ruby-3.0.3).
4415
4541
  </div>
data/doc/Shep.html CHANGED
@@ -117,7 +117,7 @@
117
117
  <dt id="Version-constant" class="">Version =
118
118
 
119
119
  </dt>
120
- <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>0.2.0-alpha0</span><span class='tstring_end'>&#39;</span></span></pre></dd>
120
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>0.2.1-alpha0</span><span class='tstring_end'>&#39;</span></span></pre></dd>
121
121
 
122
122
  </dl>
123
123
 
@@ -133,7 +133,7 @@
133
133
  </div>
134
134
 
135
135
  <div id="footer">
136
- Generated on Sat Jun 10 19:16:28 2023 by
136
+ Generated on Thu Jun 15 10:09:19 2023 by
137
137
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
138
138
  0.9.34 (ruby-3.0.3).
139
139
  </div>
data/doc/_index.html CHANGED
@@ -297,7 +297,7 @@
297
297
  </div>
298
298
 
299
299
  <div id="footer">
300
- Generated on Sat Jun 10 19:16:28 2023 by
300
+ Generated on Thu Jun 15 10:09:19 2023 by
301
301
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
302
302
  0.9.34 (ruby-3.0.3).
303
303
  </div>
data/doc/file.README.html CHANGED
@@ -168,7 +168,7 @@ honour-bound to use Shep only for good and never for evil.</p>
168
168
  </div></div>
169
169
 
170
170
  <div id="footer">
171
- Generated on Sat Jun 10 19:16:28 2023 by
171
+ Generated on Thu Jun 15 10:09:19 2023 by
172
172
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
173
173
  0.9.34 (ruby-3.0.3).
174
174
  </div>
data/doc/index.html CHANGED
@@ -168,7 +168,7 @@ honour-bound to use Shep only for good and never for evil.</p>
168
168
  </div></div>
169
169
 
170
170
  <div id="footer">
171
- Generated on Sat Jun 10 19:16:28 2023 by
171
+ Generated on Thu Jun 15 10:09:19 2023 by
172
172
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
173
173
  0.9.34 (ruby-3.0.3).
174
174
  </div>
@@ -100,7 +100,7 @@
100
100
  </div>
101
101
 
102
102
  <div id="footer">
103
- Generated on Sat Jun 10 19:16:28 2023 by
103
+ Generated on Thu Jun 15 10:09:19 2023 by
104
104
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
105
  0.9.34 (ruby-3.0.3).
106
106
  </div>
@@ -9,6 +9,9 @@ module Shep
9
9
 
10
10
  # Base class for exceptions originating from Shep. Use this to trap
11
11
  # all Shep exceptions at once.
12
+ #
13
+ # Note that Shep usually does not trap exceptions thrown by
14
+ # {Net::HTTP} and friends; you will need to trap those separately.
12
15
  class Error < RuntimeError; end
13
16
 
14
17
  # Error caused by using the interface incorrectly. *Not* the same
data/lib/shep/session.rb CHANGED
@@ -752,6 +752,40 @@ module Shep
752
752
 
753
753
  # Upload the media contained in the file at 'path'.
754
754
  #
755
+ # Requires token with sufficient permission for the account that
756
+ # owns the status.
757
+ #
758
+ # @param path [String] Path to the media file.
759
+ #
760
+ # @param content_type [String] MIME type of the media attachment.
761
+ # The default us usually all you need.
762
+ #
763
+ # @param description [String] The image description text.
764
+ #
765
+ # @param focus_x [Float] The horizontal coordinate of
766
+ # the focus on a range of -1.0
767
+ # to 1.0. This is the point in
768
+ # the image that will be the
769
+ # center of the thumbnail. If
770
+ # set, `focus_y:` must also be
771
+ # set to a valid coordinate.
772
+ #
773
+ # @param focus_y [Float] The vertical coordinate of the focus.
774
+ #
775
+ # Note that Mastodon processes attachments asynchronously, so the
776
+ # attachment may not be available for display when this method
777
+ # returns. Posting an unprocessed status as an attachment works
778
+ # as expected but it's unclear what happens between posting and
779
+ # when the processing task completes. Usually, this shouldn't
780
+ # matter to you.
781
+ #
782
+ # If a rate limit is reached during a call to this method and
783
+ # `rate_limit_retry:` was set, the media file to upload should not
784
+ # be touched in any way until the method returns.
785
+ #
786
+ # @return [Entity::MediaAttachment] The resulting MediaAttachment
787
+ # object but without the URL.
788
+ #
755
789
  # @see https://docs.joinmastodon.org/methods/media/#v2
756
790
  def upload_media(path,
757
791
  content_type: nil,
@@ -963,7 +997,7 @@ module Shep
963
997
 
964
998
  response = http_operation(request)
965
999
 
966
- result = JSON.parse(response.body)
1000
+ result = parse_json_gracefully(response.body)
967
1001
 
968
1002
  if result.is_a?(Hash) && result.has_key?("error")
969
1003
  raise Error::Server.new(result["error"])
@@ -972,8 +1006,6 @@ module Shep
972
1006
  link = parse_link_header(response["link"])
973
1007
 
974
1008
  return [result, link]
975
- rescue JSON::JSONError => e
976
- raise Error::Remote.new("Error parsing result JSON: #{e}")
977
1009
  end
978
1010
 
979
1011
  # Retrieve the resource (assumed to be binary) at 'uri' and write
@@ -983,7 +1015,9 @@ module Shep
983
1015
  request = Net::HTTP::Get.new(url, headers_for(:get))
984
1016
 
985
1017
  @logger.debug("Output file is #{filename}")
986
- File.open(filename, "wb") { |outfile| http_operation(request, outfile) }
1018
+ File.open(filename, "wb") { |outfile|
1019
+ http_operation(request, output_handle: outfile)
1020
+ }
987
1021
  @logger.debug("Done (#{filename})")
988
1022
  end
989
1023
 
@@ -1003,18 +1037,23 @@ module Shep
1003
1037
  raise Error::Caller.new("Unknown formdate type: #{formdata.class}")
1004
1038
  request.set_form(formdata, enctype)
1005
1039
 
1040
+ # IO-like devices need to be rewound before retrying the
1041
+ # request. Since Request doesn't let us have access to the
1042
+ # formdata objects, we pass them separately.
1043
+ rewinds = formdata.to_a
1044
+ .map{|name, value| value}
1045
+ .select{|value| value.respond_to?(:rewind)}
1046
+
1006
1047
  # Do the deed
1007
- response = http_operation(request)
1048
+ response = http_operation(request, rewinds: rewinds)
1008
1049
 
1009
- result = JSON.parse(response.body)
1050
+ result = parse_json_gracefully(response.body)
1010
1051
 
1011
1052
  if result.is_a?(Hash) && result.has_key?("error")
1012
1053
  raise Error::Server.new(result["error"])
1013
1054
  end
1014
1055
 
1015
1056
  return result
1016
- rescue JSON::JSONError => e
1017
- raise Error::Remote.new("Error parsing result JSON: #{e}")
1018
1057
  end
1019
1058
 
1020
1059
  def headers_for(method)
@@ -1034,7 +1073,7 @@ module Shep
1034
1073
  return headers
1035
1074
  end
1036
1075
 
1037
- def http_operation(request, output_handle = nil)
1076
+ def http_operation(request, output_handle: nil, rewinds: [])
1038
1077
  url = request.uri
1039
1078
 
1040
1079
  while true
@@ -1080,6 +1119,10 @@ module Shep
1080
1119
 
1081
1120
  return response
1082
1121
  end
1122
+
1123
+ # If we get here, we're going to try again, so we need to
1124
+ # rewind any IO-like header value.
1125
+ rewinds.each{|io| io.rewind}
1083
1126
  end
1084
1127
  end
1085
1128
  end
@@ -1111,6 +1154,12 @@ module Shep
1111
1154
  @logger.debug "Rate limit: #{rate_limit_desc}"
1112
1155
  end
1113
1156
 
1157
+ # Parse json_txt without throwing an exception. If the result
1158
+ # isn't valid, return a Mastodn-style error object instead.
1159
+ def parse_json_gracefully(json_txt)
1160
+ return JSON.parse(json_txt)
1161
+ rescue JSON::JSONError
1162
+ return {"error" => "Did not receive a valid JSON object."}
1163
+ end
1114
1164
  end
1115
-
1116
1165
  end
data/lib/shep/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Shep
3
- Version = '0.2.0-alpha0'
3
+ Version = '0.2.1-alpha0'
4
4
  end
@@ -134,3 +134,72 @@ describe Session, :tricky_ratelimit do
134
134
  .to raise_error(Shep::Error::RateLimit)
135
135
  end
136
136
  end
137
+
138
+
139
+ # Ratelimit retry is different for media uploads because the media
140
+ # file is an IO-like object that gets read as part of the upload.
141
+ # This test ensures that this also works.
142
+ #
143
+ # (It does this by uploading the same image file over and over again.
144
+ # It's a small file though, so hopefully that will minimize the stress
145
+ # we put on the server.)
146
+ describe Session, :tricky_ratelimit_media_upload do
147
+ it "expects to be configured for writing" do
148
+ expect(WRITE_ACCOUNT) .to_not be nil
149
+ end
150
+
151
+ it "rate-limit retry works with media uploads too" do
152
+
153
+ rlhook_called = false
154
+ rlhook = proc do |rl|
155
+ rlhook_called = true
156
+
157
+ delay = (rl.reset - Time.now).round
158
+ STDOUT.puts "Waiting #{delay}s for rate limit to reset."
159
+
160
+ # We stop at the 3 second mark so the underlying delay will also
161
+ # kick in.
162
+ while rl.reset - 3 >= Time.now
163
+ STDOUT.print "\r #{(rl.reset - Time.now).round} seconds "
164
+ STDOUT.flush
165
+ sleep 1
166
+ end
167
+
168
+ STDOUT.puts "\nDone!"
169
+ end
170
+
171
+ ss = Session.new(host: HOST,
172
+ token: TOKEN,
173
+ ua_comment: "(integration test; rate limit reached)",
174
+
175
+ rate_limit_retry: true,
176
+ retry_hook: rlhook,
177
+
178
+ logger: :info
179
+ )
180
+
181
+ media_file = File.join(File.dirname(__FILE__), "data", "smallimg.jpg")
182
+
183
+ limit = nil
184
+ count = 0
185
+ while !rlhook_called
186
+ ma = ss.upload_media(media_file)
187
+
188
+ # First pass, we fetch the deletion limit
189
+ limit = ss.rate_limit.limit unless limit
190
+
191
+ STDOUT.print "."
192
+ STDOUT.flush
193
+
194
+ count += 1
195
+ end
196
+
197
+ # Ensure we did at least one iteration
198
+ expect( rlhook_called ) .to be true
199
+ expect( count ) .to be >= 1
200
+
201
+ # And ensure that we can do another post/delete cycle
202
+ ma = ss.upload_media(media_file)
203
+ expect( ma.id ) .to_not be nil # kind of redundant, but whatever
204
+ end
205
+ end
data/yard_helper.rb CHANGED
@@ -6,6 +6,11 @@ class EntityFieldDeclHandler < YARD::Handlers::Ruby::Base #AttributeHandler
6
6
  namespace_only
7
7
 
8
8
  process do
9
+ sanitized = {
10
+ '<' => '&lt;',
11
+ '>' => '&gt;',
12
+ }
13
+
9
14
  mastotype = namespace.name.to_s.gsub(/_/, '::')
10
15
  new_docstr = "Ruby object representing a Mastodon `#{mastotype}` object:\n\n"
11
16
 
@@ -15,9 +20,13 @@ class EntityFieldDeclHandler < YARD::Handlers::Ruby::Base #AttributeHandler
15
20
  # completely done fighting with YARD to get it to recognize my
16
21
  # 'attr' tags.
17
22
 
18
- new_docstr += " * #{name} (#{type.to_yard_s})\n"
23
+ typename = type.to_yard_s
24
+ .gsub(/[<>]/) {|match| sanitized[match]} # Excape angle brackets
25
+ .gsub(/(Entity::\w+)/, '{\1}') # So YARD can generate refs
26
+
27
+ new_docstr += " * #{name} (#{typename})\n"
19
28
  end
20
-
29
+
21
30
  new_docstr += "\n"
22
31
  new_docstr += "See `Shep::Entity` for an overview.\n\n"
23
32
  new_docstr += namespace.docstring.to_raw.strip
@@ -25,6 +34,3 @@ class EntityFieldDeclHandler < YARD::Handlers::Ruby::Base #AttributeHandler
25
34
  namespace.docstring.replace(new_docstr)
26
35
  end
27
36
  end
28
-
29
-
30
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.pre.alpha0
4
+ version: 0.2.1.pre.alpha0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Reuter