activitypub 0.5.3 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/get_actor.rb +3 -0
- data/lib/activitypub/base.rb +11 -5
- data/lib/activitypub/uri.rb +6 -6
- 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: 50edef028c0ec645b4cbe978e667f0a555d695627f5690c63f051e8760748a8d
|
4
|
+
data.tar.gz: b16ded843906e72291472b24c6304eb7ae70d0d7702e4ffaec797e921836d018
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e908f7467abf62226e6be34373bbcb3a9f0a33a8761360dcc9f12ceae7d3dbe848ad57e706a4b2a53fee330985977b129828fd331189e1386c58059d9999718b
|
7
|
+
data.tar.gz: 5996073206adcbf572234cc08af6fd3b4d83b48457a11df7f47374fd2a5093a46d4fc947a126173d7943e0eb7d8a5dd440a81c992ed021160c01a10372a48001
|
data/examples/get_actor.rb
CHANGED
@@ -36,6 +36,7 @@ puts "Enter to continue"
|
|
36
36
|
gets
|
37
37
|
|
38
38
|
puts "Trying to retrieve outbox"
|
39
|
+
p ob.outbox
|
39
40
|
ob = ob.outbox.get
|
40
41
|
PP.pp(ob)
|
41
42
|
puts
|
@@ -48,6 +49,8 @@ ob = ob.first.get
|
|
48
49
|
PP.pp(ob)
|
49
50
|
|
50
51
|
# For now, this will let you iterate through the collection.
|
52
|
+
|
53
|
+
|
51
54
|
# while ob && ob.orderedItems.length > 0
|
52
55
|
# PP.pp ob.id
|
53
56
|
# ob = ob.next&.get
|
data/lib/activitypub/base.rb
CHANGED
@@ -6,22 +6,27 @@ module ActivityPub
|
|
6
6
|
class Error < StandardError; end
|
7
7
|
|
8
8
|
|
9
|
-
def self.from_json(json, resolver: nil)
|
10
|
-
from_hash(JSON.parse(json), resolver:)
|
9
|
+
def self.from_json(json, resolver: nil, allow_unknown: false)
|
10
|
+
from_hash(JSON.parse(json), resolver:, allow_unknown:)
|
11
11
|
end
|
12
12
|
|
13
|
-
def self.from_hash(h, resolver: nil)
|
13
|
+
def self.from_hash(h, resolver: nil, allow_unknown: false)
|
14
14
|
type = h&.dig("type")
|
15
15
|
|
16
16
|
raise Error, "'type' attribute is required" if !type
|
17
17
|
raise NameError, "'type' attribute with '::' is not allowed" if !type.index("::").nil?
|
18
18
|
|
19
19
|
# FIXME: May need a way to override/handle custom namespaces.
|
20
|
-
|
21
|
-
|
20
|
+
|
21
|
+
if allow_unknown && !ActivityPub.const_defined?(type)
|
22
|
+
klass = ActivityPub::Object
|
23
|
+
else
|
24
|
+
klass = ActivityPub.const_get(type)
|
25
|
+
end
|
22
26
|
|
23
27
|
ob = klass ? klass.new : nil
|
24
28
|
ob._resolver = resolver
|
29
|
+
ob._raw = h
|
25
30
|
|
26
31
|
# FIXME: Useful for debug. Add flag to allow enabling.
|
27
32
|
# ob.instance_variable_set("@_raw",h)
|
@@ -60,6 +65,7 @@ module ActivityPub
|
|
60
65
|
def _type = self.class.name.split("::").last
|
61
66
|
|
62
67
|
attr_accessor :_resolver
|
68
|
+
attr_accessor :_raw
|
63
69
|
|
64
70
|
|
65
71
|
# FIXME: Allow specifying a type (e.g. URI)
|
data/lib/activitypub/uri.rb
CHANGED
@@ -3,18 +3,18 @@ require_relative 'resolvers'
|
|
3
3
|
|
4
4
|
module ActivityPub
|
5
5
|
class URI
|
6
|
-
|
6
|
+
attr_writer :_resolver
|
7
7
|
|
8
8
|
def initialize(href, resolver: nil)
|
9
9
|
@href = href
|
10
|
-
@_resolver = resolver
|
10
|
+
@_resolver = resolver
|
11
11
|
end
|
12
12
|
|
13
|
+
def _resolver = (@_resolver || WebResolver)
|
14
|
+
|
13
15
|
def to_s = @href
|
14
16
|
def to_json(...) = @href
|
15
|
-
|
16
|
-
def get
|
17
|
-
@_resolver&.call(self.to_s)
|
18
|
-
end
|
17
|
+
|
18
|
+
def get = _resolver.call(self.to_s)
|
19
19
|
end
|
20
20
|
end
|
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.5.
|
4
|
+
version: 0.5.5
|
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-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: webfinger
|