activitypub 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1ca73a9e32bd5ed6fe6fc28cdeeaae31b82d498c433ecc7b814362ab0d55833
4
- data.tar.gz: 3843cf8bd348e19771798efe7557ec6e2701e21734e22a784a2340dffe328d9e
3
+ metadata.gz: 26d9d9069a471b10cb01a4ab0989098f6e9b6d3736d4f3c9739844de63b57e43
4
+ data.tar.gz: 34fe597a239e1ef1a16765a53ca4554000c8e6c97354f984dfdc583ed579f9c4
5
5
  SHA512:
6
- metadata.gz: 5c0ddf7fd8672ba4d44b7f3f9b894625a2b279e0bd2c0f867a74a1da45ab462dc04d530dd2430c8ec5065b7c4ce1b4282fa5dc79a1a4a85b04fdb48bdb38148e
7
- data.tar.gz: 69ad1655d931018f102e2b8c25cf5e2310803fc3a5ca4fc02a2192e9b0ccfd74cf59cc8891fbacb96c3ee69c17fddf5af594738aaf0a65042a9d950fb77d09f5
6
+ metadata.gz: e06d022fd40649670cf3133c90ab05935d96c6747a4fc3899a266492ee03c767b21407103d111e5ff6b23f351349d9c99cd2c9de03768eeafbd4e8e025291c60
7
+ data.tar.gz: ad8f7d544c4565518866825845a95e27d48c5ccc384595db4d627916d3990d772c9f9b3ca2aafd7a6a98263117cb37c89e1e23350fb30b2a3b19b6ca8a1b4f4f
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Activitypub
1
+ # ActivityPub
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ *Very* early start on a set of classes to serialize/deserialize
4
+ ActivityPub/ActivityStream objects.
4
5
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/activitypub`. To experiment with that code, run `bin/console` for an interactive prompt.
6
6
 
7
7
  ## Installation
8
8
 
@@ -0,0 +1,41 @@
1
+
2
+ module ActivityPub
3
+
4
+ # This is not part of ActivityPub, but provides basic mechanisms
5
+ # for serialization and dezerialisation.
6
+ #
7
+ class Base
8
+ def _context = "https://www.w3.org/ns/activitystreams"
9
+ def _type = self.class.name.split("::").last
10
+
11
+
12
+ def self.ap_attr(*names)
13
+ @ap_attributes ||= []
14
+ @ap_attributes.concat(names)
15
+ attr_accessor *names
16
+ end
17
+
18
+ def self.ap_attributes
19
+ parent = superclass.respond_to?(:ap_attributes) ? superclass.ap_attributes : []
20
+ parent.concat(@ap_attributes||[])
21
+ end
22
+
23
+ def to_h
24
+ h = {
25
+ "@context" => _context,
26
+ "type" => _type,
27
+ }
28
+
29
+ self.class.ap_attributes.each do |attr|
30
+ val = instance_variable_get("@#{attr}")
31
+ h[attr.to_s] = val if val
32
+ end
33
+
34
+ h
35
+ end
36
+
37
+ def to_json(...) = to_h.to_json(...)
38
+ end
39
+
40
+
41
+ end
@@ -0,0 +1,169 @@
1
+
2
+ # https://www.w3.org/TR/activitystreams-vocabulary/
3
+
4
+ require_relative 'base'
5
+
6
+ module ActivityPub
7
+
8
+ class Link < Base
9
+ ap_attr :href, :rel, :mediaType, :name, :hreflang, :height, :width, :preview
10
+ end
11
+
12
+ class Object < Base
13
+ ap_attr :attachment, :attributedTo, :audience, :content, :context,
14
+ :name, :endTime, :generator, :icon, :image, :inReplyTo, :location,
15
+ :preview, :published, :replies, :startTime, :summary, :tag, :updated,
16
+ :url, :to, :bto, :cc, :mediaType, :duration
17
+ end
18
+
19
+ class Activity < Object
20
+ ap_attr :actor, :object, :target, :result, :origin, :instrument
21
+ end
22
+
23
+ # @FIXME
24
+ # All attributes from Activity *except* object.
25
+ class IntransitiveActivity < Activity
26
+ end
27
+
28
+ class Collection < Object
29
+ ap_attr :totalItems, :current, :first, :last, :items
30
+ end
31
+
32
+ class OrderedCollection < Collection
33
+ end
34
+
35
+ class CollectionPage < Collection
36
+ ap_attr :partOf, :next, :prev
37
+ end
38
+
39
+ class OrderedCollectionPage < CollectionPage
40
+ ap_attr :startIndex
41
+ end
42
+
43
+ # ## ActivityTypes
44
+
45
+ class Accept < Activity
46
+ end
47
+
48
+ class TentativeAccept < Accept
49
+ end
50
+
51
+ class Add < Activity
52
+ end
53
+
54
+ class Arrive < IntransitiveActivity
55
+ end
56
+
57
+ class Create < Activity
58
+ end
59
+
60
+ class Delete < Activity
61
+ end
62
+
63
+ class Follow < Activity
64
+ end
65
+
66
+ class Ignore < Activity
67
+ end
68
+
69
+ class Join < Activity
70
+ end
71
+
72
+ class Leave < Activity
73
+ end
74
+
75
+ class Like < Activity
76
+ end
77
+
78
+ class Offer < Activity
79
+ end
80
+
81
+ class Invite < Offer
82
+ end
83
+
84
+ class Reject < Activity
85
+ end
86
+
87
+ class TentativeReject < Reject
88
+ end
89
+
90
+ class Remove < Activity
91
+ end
92
+
93
+ class Undo < Activity
94
+ end
95
+
96
+ class Update < Activity
97
+ end
98
+
99
+ class View < Activity
100
+ end
101
+
102
+ class Listen < Activity
103
+ end
104
+
105
+ class Move < Activity
106
+ end
107
+
108
+ class Travel < IntransitiveActivity
109
+ end
110
+
111
+ class Announce < Activity
112
+ end
113
+
114
+ class Block < Ignore
115
+ end
116
+
117
+ class Flag < Activity
118
+ end
119
+
120
+ class Dislike < Activity
121
+ end
122
+
123
+ class Question < IntransitiveActivity
124
+ ap_attr :oneOf, :anyOf, :closed
125
+ end
126
+
127
+ # ## Object types
128
+
129
+ class Relationship < Object
130
+ ap_attr :subject, :object, :relationship
131
+ end
132
+
133
+ class Article < Object
134
+ end
135
+
136
+ class Document < Object
137
+ end
138
+
139
+ class Audio < Document
140
+ end
141
+
142
+ class Image < Document
143
+ end
144
+
145
+ class Video < Document
146
+ end
147
+
148
+ class Note < Object
149
+ end
150
+
151
+ class Page < Object
152
+ end
153
+
154
+ class Event < Object
155
+ end
156
+
157
+ class Place < Object
158
+ end
159
+
160
+ class Mention < Link
161
+ end
162
+
163
+ class Profile < Object
164
+ end
165
+
166
+ class Tombstone < Object
167
+ ap_attr :formerType, :deleted
168
+ end
169
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActivityPub
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/activitypub.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "activitypub/version"
4
+ require_relative "activitypub/types"
4
5
 
5
6
  module ActivityPub
6
7
  class Error < StandardError; end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activitypub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vidar Hokstad
@@ -21,6 +21,8 @@ files:
21
21
  - README.md
22
22
  - Rakefile
23
23
  - lib/activitypub.rb
24
+ - lib/activitypub/base.rb
25
+ - lib/activitypub/types.rb
24
26
  - lib/activitypub/version.rb
25
27
  - sig/activitypub.rbs
26
28
  homepage: https://github.com/vidarh/activitypub