activitypub 0.4.0 → 0.4.2
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 +4 -4
- data/README.md +11 -3
- data/examples/get_actor.rb +15 -1
- data/lib/activitypub/base.rb +4 -1
- data/lib/activitypub/types.rb +27 -10
- data/lib/activitypub/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56987420fcce47e1c1c7e1244f804a49bd9e83d80d161c63f90af8ad05c0b669
|
4
|
+
data.tar.gz: a80c527aa688521d97671dcfdbcb3eb55d2b35168fb2dcf1bee5c9ef92123d01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e6b1f21ab13dfa05f3d9c44f1b3ccf71cc09b83af207800f99dd1ed1d89876cbd3c123385232652285a0e9227edc762a2f8010050f194930d783d11efa4a929
|
7
|
+
data.tar.gz: 9cfdb2e7f56a4b01dfd46f376adbf40843d28347af49d7f281f7588c7650920f29fc1df0b411b45ee9c867c709e71a87d92d3f7d73cf0b133d1375d98db02308
|
data/README.md
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
# ActivityPub
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
A Ruby gem to make it easy to retrieve and work with ActivityPub/
|
4
|
+
ActivityStreams objects, as used in Mastodon, Lemmy, Pixelfed and
|
5
|
+
similar.
|
6
|
+
|
7
|
+
CAUTION: This is early days and the API is likely to change quickly.
|
8
|
+
If you want to start using this, please follow the project and/or let
|
9
|
+
me know.
|
5
10
|
|
6
11
|
## Goals
|
7
12
|
|
@@ -28,7 +33,10 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
28
33
|
|
29
34
|
## Usage
|
30
35
|
|
31
|
-
TODO: Write usage instructions here
|
36
|
+
TODO: Write usage instructions here.
|
37
|
+
|
38
|
+
For now your best bet is to look at the examples/ dir and the unit
|
39
|
+
tests.
|
32
40
|
|
33
41
|
## Development
|
34
42
|
|
data/examples/get_actor.rb
CHANGED
@@ -30,7 +30,7 @@ puts
|
|
30
30
|
|
31
31
|
ob = href.get
|
32
32
|
PP.pp(ob)
|
33
|
-
puts ob.to_json
|
33
|
+
#puts ob.to_json
|
34
34
|
puts
|
35
35
|
puts "Enter to continue"
|
36
36
|
gets
|
@@ -38,3 +38,17 @@ gets
|
|
38
38
|
puts "Trying to retrieve outbox"
|
39
39
|
ob = ob.outbox.get
|
40
40
|
PP.pp(ob)
|
41
|
+
puts
|
42
|
+
puts "Enter to continue"
|
43
|
+
gets
|
44
|
+
|
45
|
+
puts
|
46
|
+
puts "PAGE: #{ob.first}"
|
47
|
+
ob = ob.first.get
|
48
|
+
PP.pp(ob)
|
49
|
+
|
50
|
+
# For now, this will let you iterate through the collection.
|
51
|
+
# while ob && ob.orderedItems.length > 0
|
52
|
+
# PP.pp ob.id
|
53
|
+
# ob = ob.next&.get
|
54
|
+
# end
|
data/lib/activitypub/base.rb
CHANGED
@@ -22,6 +22,9 @@ module ActivityPub
|
|
22
22
|
|
23
23
|
ob = klass ? klass.new : nil
|
24
24
|
|
25
|
+
# FIXME: Useful for debug. Add flag to allow enabling.
|
26
|
+
# ob.instance_variable_set("@_raw",h)
|
27
|
+
|
25
28
|
if ob
|
26
29
|
context = h.dig("@context")
|
27
30
|
ob.instance_variable_set("@_context", context) if context
|
@@ -38,7 +41,7 @@ module ActivityPub
|
|
38
41
|
end
|
39
42
|
|
40
43
|
if t = klass.ap_types[attr]
|
41
|
-
v = t.new(v)
|
44
|
+
v = t.new(v) if v
|
42
45
|
end
|
43
46
|
ob.instance_variable_set("@#{attr}", v) if !v.nil?
|
44
47
|
end
|
data/lib/activitypub/types.rb
CHANGED
@@ -7,8 +7,13 @@ require_relative 'uri'
|
|
7
7
|
module ActivityPub
|
8
8
|
|
9
9
|
class Link < Base
|
10
|
-
ap_attr :href
|
10
|
+
ap_attr :href, URI
|
11
|
+
|
12
|
+
# We don't mark "rel" as a URI as it's effectively
|
13
|
+
# used as an identifier for comparison rather than to
|
14
|
+
# dereference
|
11
15
|
ap_attr :rel
|
16
|
+
|
12
17
|
ap_attr :mediaType
|
13
18
|
ap_attr :name
|
14
19
|
ap_attr :hreflang
|
@@ -29,7 +34,7 @@ module ActivityPub
|
|
29
34
|
ap_attr :generator
|
30
35
|
ap_attr :icon
|
31
36
|
ap_attr :image
|
32
|
-
ap_attr :inReplyTo
|
37
|
+
ap_attr :inReplyTo, URI
|
33
38
|
ap_attr :location
|
34
39
|
ap_attr :preview
|
35
40
|
ap_attr :published
|
@@ -38,7 +43,7 @@ module ActivityPub
|
|
38
43
|
ap_attr :summary
|
39
44
|
ap_attr :tag
|
40
45
|
ap_attr :updated
|
41
|
-
ap_attr :url
|
46
|
+
ap_attr :url, URI
|
42
47
|
ap_attr :to
|
43
48
|
ap_attr :bto
|
44
49
|
ap_attr :cc
|
@@ -63,9 +68,12 @@ module ActivityPub
|
|
63
68
|
class Collection < Object
|
64
69
|
ap_attr :totalItems
|
65
70
|
ap_attr :current
|
66
|
-
ap_attr :first
|
67
|
-
ap_attr :last
|
71
|
+
ap_attr :first, URI
|
72
|
+
ap_attr :last, URI
|
68
73
|
ap_attr :items
|
74
|
+
|
75
|
+
def each(...) = Array(items).each(...)
|
76
|
+
def map(...) = Array(items).map(...)
|
69
77
|
end
|
70
78
|
|
71
79
|
class OrderedCollection < Collection
|
@@ -76,15 +84,24 @@ module ActivityPub
|
|
76
84
|
#
|
77
85
|
# FIXME: Review/consider whether to marge orderedItems/items internally.
|
78
86
|
ap_attr :orderedItems
|
87
|
+
|
88
|
+
def each(...) = Array(orderedItems).each(...)
|
89
|
+
def map(...) = Array(orderedItems).map(...)
|
79
90
|
end
|
80
91
|
|
81
92
|
class CollectionPage < Collection
|
82
|
-
ap_attr :partOf
|
83
|
-
ap_attr :next
|
84
|
-
ap_attr :prev
|
93
|
+
ap_attr :partOf, URI
|
94
|
+
ap_attr :next, URI
|
95
|
+
ap_attr :prev, URI
|
85
96
|
end
|
86
|
-
|
87
|
-
|
97
|
+
|
98
|
+
# FIXME: OrderedCollectionPage inherits both CollectionPage and
|
99
|
+
# OrderedCollection.
|
100
|
+
#
|
101
|
+
class OrderedCollectionPage < OrderedCollection
|
102
|
+
ap_attr :partOf, URI
|
103
|
+
ap_attr :next, URI
|
104
|
+
ap_attr :prev, URI
|
88
105
|
ap_attr :startIndex
|
89
106
|
end
|
90
107
|
|
data/lib/activitypub/version.rb
CHANGED
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.4.
|
4
|
+
version: 0.4.2
|
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
|
+
date: 2024-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: webfinger
|