activitypub 0.3.7 → 0.4.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: 58943510abdbebb4cce7084adcd2fd5c587abed81f103db968148248a9b1e7c1
4
- data.tar.gz: 5ccd6bd6cff637fdc5717d064b8b02a29282c9e6d7549c8ad322bd30a0ce2503
3
+ metadata.gz: 1c8cae4b7204912811e11efa38d689ee0cb418c480a7e3240a70a8d4dcafd699
4
+ data.tar.gz: 4c732f4669c8ed60428d75b45bda5aac7ffa24e439d9fc4f8c733e51241438f3
5
5
  SHA512:
6
- metadata.gz: 7a8b4a3a8cdac1be9d069c47b413d00573640ad59e0deca098bf0a0b5f06124bd3c2a43b66462b2f3bf23b3b187c0de55478878b875fa38674b7c53eac968b54
7
- data.tar.gz: c4981e523c2754b2d83c9cf6f52fc6de61353b3373097a55b5531f325b08c1477195ba7bac58f3ee47eb3138cb743d06c1719f61e3779a06a3f9b45112011770
6
+ metadata.gz: 3f5e26e20e624d3c9ae77f66832e8ed6bee1516c84ec4cc1ef2d24f47b468c2e473ee15e4ecab7e000e910adef998870df26650aa7060753d5430dfb699c8717
7
+ data.tar.gz: 40cfe87f071e5b8be1e6848f86232523f206e90b8b78c25ad9be0b7aa29c7b72f3da6c64da669edc384424c1e7ea9b4b5f813a15c0b1816ee3360568ec5d40cf
@@ -30,10 +30,11 @@ puts
30
30
 
31
31
  ob = href.get
32
32
  PP.pp(ob)
33
+ puts ob.to_json
33
34
  puts
34
35
  puts "Enter to continue"
35
36
  gets
36
37
 
37
38
  puts "Trying to retrieve outbox"
38
- ob = ActivityPub::URI.new(ob.outbox).get
39
+ ob = ob.outbox.get
39
40
  PP.pp(ob)
@@ -36,8 +36,9 @@ module ActivityPub
36
36
  av.is_a?(Hash) && av["type"] ? from_hash(av) : av
37
37
  end
38
38
  end
39
- if attr.to_s == "href" && v.is_a?(String)
40
- v = ActivityPub::URI.new(v)
39
+
40
+ if t = klass.ap_types[attr]
41
+ v = t.new(v)
41
42
  end
42
43
  ob.instance_variable_set("@#{attr}", v) if !v.nil?
43
44
  end
@@ -55,12 +56,19 @@ module ActivityPub
55
56
 
56
57
 
57
58
  # FIXME: Allow specifying a type (e.g. URI)
58
- def self.ap_attr(*names)
59
+ def self.ap_attr(name, type=nil)
59
60
  @ap_attributes ||= []
60
- @ap_attributes.concat(names)
61
- attr_accessor *names
61
+ @ap_attributes << name
62
+ @ap_types ||= {}
63
+ @ap_types[name] = type
64
+ attr_accessor name
62
65
  end
63
66
 
67
+ def self.ap_types
68
+ parent = superclass.respond_to?(:ap_types) ? superclass.ap_types : {}
69
+ parent.merge(@ap_types || {})
70
+ end
71
+
64
72
  def self.ap_attributes
65
73
  parent = superclass.respond_to?(:ap_attributes) ? superclass.ap_attributes : []
66
74
  parent.concat(@ap_attributes||[])
@@ -7,19 +7,52 @@ require_relative 'uri'
7
7
  module ActivityPub
8
8
 
9
9
  class Link < Base
10
- ap_attr :href, :rel, :mediaType, :name, :hreflang, :height, :width, :preview
10
+ ap_attr :href
11
+ ap_attr :rel
12
+ ap_attr :mediaType
13
+ ap_attr :name
14
+ ap_attr :hreflang
15
+ ap_attr :height
16
+ ap_attr :width
17
+ ap_attr :preview
11
18
  end
12
19
 
13
20
  class Object < Base
14
21
  ap_attr :id
15
- ap_attr :attachment, :attributedTo, :audience, :content, :context,
16
- :name, :endTime, :generator, :icon, :image, :inReplyTo, :location,
17
- :preview, :published, :replies, :startTime, :summary, :tag, :updated,
18
- :url, :to, :bto, :cc, :mediaType, :duration
22
+ ap_attr :attachment
23
+ ap_attr :attributedTo
24
+ ap_attr :audience
25
+ ap_attr :content
26
+ ap_attr :context
27
+ ap_attr :name
28
+ ap_attr :endTime
29
+ ap_attr :generator
30
+ ap_attr :icon
31
+ ap_attr :image
32
+ ap_attr :inReplyTo
33
+ ap_attr :location
34
+ ap_attr :preview
35
+ ap_attr :published
36
+ ap_attr :replies
37
+ ap_attr :startTime
38
+ ap_attr :summary
39
+ ap_attr :tag
40
+ ap_attr :updated
41
+ ap_attr :url
42
+ ap_attr :to
43
+ ap_attr :bto
44
+ ap_attr :cc
45
+ ap_attr :mediaType
46
+ ap_attr :duration
19
47
  end
20
48
 
21
49
  class Activity < Object
22
- ap_attr :actor, :object, :target, :result, :origin, :instrument
50
+ ap_attr :actor
51
+ ap_attr :object
52
+ ap_attr :target
53
+ ap_attr :result
54
+ ap_attr :origin
55
+ ap_attr :instrument
23
56
  end
24
57
 
25
58
  # @FIXME
@@ -28,7 +61,11 @@ module ActivityPub
28
61
  end
29
62
 
30
63
  class Collection < Object
31
- ap_attr :totalItems, :current, :first, :last, :items
64
+ ap_attr :totalItems
65
+ ap_attr :current
66
+ ap_attr :first
67
+ ap_attr :last
68
+ ap_attr :items
32
69
  end
33
70
 
34
71
  class OrderedCollection < Collection
@@ -42,7 +79,9 @@ module ActivityPub
42
79
  end
43
80
 
44
81
  class CollectionPage < Collection
45
- ap_attr :partOf, :next, :prev
82
+ ap_attr :partOf
83
+ ap_attr :next
84
+ ap_attr :prev
46
85
  end
47
86
 
48
87
  class OrderedCollectionPage < CollectionPage
@@ -130,7 +169,9 @@ module ActivityPub
130
169
  end
131
170
 
132
171
  class Question < IntransitiveActivity
133
- ap_attr :oneOf, :anyOf, :closed
172
+ ap_attr :oneOf
173
+ ap_attr :anyOf
174
+ ap_attr :closed
134
175
  end
135
176
 
136
177
  # ## Actor Types
@@ -144,20 +185,27 @@ module ActivityPub
144
185
  # Section 4.1
145
186
 
146
187
  # MUST have:
147
- ap_attr :inbox, :outbox
188
+ ap_attr :inbox, URI
189
+ ap_attr :outbox, URI
148
190
 
149
191
  # SHOULD have:
150
- ap_attr :following, :followers
192
+ ap_attr :following
193
+ ap_attr :followers
151
194
 
152
195
  # MAY have:
153
- ap_attr :liked, :streams, :preferredUsername,
154
- :endpoints
196
+ ap_attr :liked
197
+ ap_attr :streams
198
+ ap_attr :preferredUsername
199
+ ap_attr :endpoints
155
200
 
156
201
 
157
202
  # Per https://docs-p.joinmastodon.org/spec/activitypub/#extensions
158
203
  # These are extensions used by Mastodon for Actor types
159
- ap_attr :publicKey, :featured, :featuredTags,
160
- :discoverable, :suspended
204
+ ap_attr :publicKey
205
+ ap_attr :featured
206
+ ap_attr :featuredTags
207
+ ap_attr :discoverable
208
+ ap_attr :suspended
161
209
  end
162
210
 
163
211
  # FIXME: Add "toot:Emoji
@@ -173,7 +221,9 @@ module ActivityPub
173
221
 
174
222
  # Mastodon extension per
175
223
  # https://docs-p.joinmastodon.org/spec/activitypub/#extensions
176
- ap_attr :likes, :bookmarks, :manuallyApprovesFollowers
224
+ ap_attr :likes
225
+ ap_attr :bookmarks
226
+ ap_attr :manuallyApprovesFollowers
177
227
  end
178
228
 
179
229
  class Service < Actor
@@ -183,7 +233,9 @@ module ActivityPub
183
233
  # ## Object types
184
234
 
185
235
  class Relationship < Object
186
- ap_attr :subject, :object, :relationship
236
+ ap_attr :subject
237
+ ap_attr :object
238
+ ap_attr :relationship
187
239
  end
188
240
 
189
241
  class Article < Object
@@ -199,7 +251,8 @@ module ActivityPub
199
251
 
200
252
  # Mastodon extension per
201
253
  # https://docs-p.joinmastodon.org/spec/activitypub/#extensions
202
- ap_attr :focalPoint, :blurhash
254
+ ap_attr :focalPoint
255
+ ap_attr :blurhash
203
256
  end
204
257
 
205
258
  class Video < Document
@@ -224,7 +277,8 @@ module ActivityPub
224
277
  end
225
278
 
226
279
  class Tombstone < Object
227
- ap_attr :formerType, :deleted
280
+ ap_attr :formerType
281
+ ap_attr :deleted
228
282
  end
229
283
 
230
284
  # Mastodon extensions
@@ -9,7 +9,7 @@ module ActivityPub
9
9
  end
10
10
 
11
11
  def to_s = @href
12
- def to_json = @href
12
+ def to_json(...) = @href
13
13
 
14
14
  def get
15
15
  response = Faraday.get(self.to_s, {}, {"Accept": "application/activity+json"})
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActivityPub
4
- VERSION = "0.3.7"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activitypub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vidar Hokstad
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-11 00:00:00.000000000 Z
11
+ date: 2024-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: webfinger