todon-api 2.0.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 +7 -0
- data/lib/mastodon/access_token.rb +21 -0
- data/lib/mastodon/account.rb +73 -0
- data/lib/mastodon/app.rb +17 -0
- data/lib/mastodon/base.rb +50 -0
- data/lib/mastodon/card.rb +41 -0
- data/lib/mastodon/client.rb +28 -0
- data/lib/mastodon/collection.rb +27 -0
- data/lib/mastodon/conversation.rb +25 -0
- data/lib/mastodon/emoji.rb +21 -0
- data/lib/mastodon/entities/app.rb +12 -0
- data/lib/mastodon/entities/hashtag.rb +12 -0
- data/lib/mastodon/entities/media.rb +28 -0
- data/lib/mastodon/entities/mention.rb +14 -0
- data/lib/mastodon/error.rb +34 -0
- data/lib/mastodon/field.rb +18 -0
- data/lib/mastodon/filter.rb +29 -0
- data/lib/mastodon/hashtag.rb +19 -0
- data/lib/mastodon/headers.rb +17 -0
- data/lib/mastodon/instance.rb +33 -0
- data/lib/mastodon/list.rb +15 -0
- data/lib/mastodon/media.rb +34 -0
- data/lib/mastodon/notification.rb +30 -0
- data/lib/mastodon/relationship.rb +41 -0
- data/lib/mastodon/rest/accounts.rb +87 -0
- data/lib/mastodon/rest/api.rb +45 -0
- data/lib/mastodon/rest/apps.rb +27 -0
- data/lib/mastodon/rest/client.rb +10 -0
- data/lib/mastodon/rest/conversations.rb +34 -0
- data/lib/mastodon/rest/custom_emojis.rb +16 -0
- data/lib/mastodon/rest/domain_blocks.rb +32 -0
- data/lib/mastodon/rest/endorsements.rb +36 -0
- data/lib/mastodon/rest/filters.rb +61 -0
- data/lib/mastodon/rest/instances.rb +28 -0
- data/lib/mastodon/rest/lists.rb +77 -0
- data/lib/mastodon/rest/media.rb +31 -0
- data/lib/mastodon/rest/notifications.rb +34 -0
- data/lib/mastodon/rest/relationships.rb +126 -0
- data/lib/mastodon/rest/reports.rb +20 -0
- data/lib/mastodon/rest/request.rb +41 -0
- data/lib/mastodon/rest/scheduled_statuses.rb +43 -0
- data/lib/mastodon/rest/search.rb +20 -0
- data/lib/mastodon/rest/statuses.rb +124 -0
- data/lib/mastodon/rest/suggestions.rb +27 -0
- data/lib/mastodon/rest/timelines.rb +60 -0
- data/lib/mastodon/rest/utils.rb +40 -0
- data/lib/mastodon/results.rb +18 -0
- data/lib/mastodon/scheduled_status.rb +25 -0
- data/lib/mastodon/status.rb +96 -0
- data/lib/mastodon/streaming/client.rb +97 -0
- data/lib/mastodon/streaming/connection.rb +44 -0
- data/lib/mastodon/streaming/events/filters_change.rb +7 -0
- data/lib/mastodon/streaming/events/status_delete.rb +16 -0
- data/lib/mastodon/streaming/message_parser.rb +23 -0
- data/lib/mastodon/streaming/response.rb +43 -0
- data/lib/mastodon/version.rb +29 -0
- data/lib/mastodon.rb +6 -0
- data/mastodon.gemspec +23 -0
- metadata +175 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'mastodon/status'
|
2
|
+
require 'mastodon/conversation'
|
3
|
+
require 'mastodon/streaming/events/filters_change'
|
4
|
+
require 'mastodon/streaming/events/status_delete'
|
5
|
+
|
6
|
+
module Mastodon
|
7
|
+
module Streaming
|
8
|
+
class MessageParser
|
9
|
+
MESSAGE_TYPES = {
|
10
|
+
'update' => Status,
|
11
|
+
'notification' => Notification,
|
12
|
+
'conversation' => Conversation,
|
13
|
+
'delete' => Events::StatusDelete,
|
14
|
+
'filters_changed' => Events::FiltersChange,
|
15
|
+
}.freeze
|
16
|
+
|
17
|
+
def self.parse(type, data)
|
18
|
+
klass = MESSAGE_TYPES[type]
|
19
|
+
klass.new(data) if klass
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'buftok'
|
2
|
+
require 'http'
|
3
|
+
require 'json'
|
4
|
+
require 'mastodon/error'
|
5
|
+
|
6
|
+
module Mastodon
|
7
|
+
module Streaming
|
8
|
+
class Response
|
9
|
+
# Initializes a new Response object
|
10
|
+
#
|
11
|
+
# @return [Mastodon::Streaming::Response]
|
12
|
+
def initialize(&block)
|
13
|
+
@block = block
|
14
|
+
@parser = HTTP::Response::Parser.new
|
15
|
+
@tokenizer = BufferedTokenizer.new("\n\n")
|
16
|
+
@match = Regexp.new(/event: ([a-z]+)\ndata: (.+)/m)
|
17
|
+
end
|
18
|
+
|
19
|
+
def <<(data)
|
20
|
+
@parser.add(data)
|
21
|
+
error = Mastodon::Error::ERRORS[@parser.status_code]
|
22
|
+
raise error if error
|
23
|
+
end
|
24
|
+
|
25
|
+
# @note this does get called
|
26
|
+
def on_headers_complete(_headers)
|
27
|
+
@finished[:headers] = true
|
28
|
+
end
|
29
|
+
|
30
|
+
def on_body(data)
|
31
|
+
@tokenizer.extract(data).each do |line|
|
32
|
+
has_data = @match.match(line)
|
33
|
+
next if has_data.nil?
|
34
|
+
|
35
|
+
type = has_data[1]
|
36
|
+
data = has_data[2]
|
37
|
+
|
38
|
+
@block.call(type, JSON.parse(data))
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Mastodon
|
2
|
+
module Version
|
3
|
+
module_function
|
4
|
+
|
5
|
+
def major
|
6
|
+
2
|
7
|
+
end
|
8
|
+
|
9
|
+
def minor
|
10
|
+
0
|
11
|
+
end
|
12
|
+
|
13
|
+
def patch
|
14
|
+
0
|
15
|
+
end
|
16
|
+
|
17
|
+
def pre
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_a
|
22
|
+
[major, minor, patch, pre].compact
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_s
|
26
|
+
to_a.join('.')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/mastodon.rb
ADDED
data/mastodon.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'mastodon/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'todon-api'
|
7
|
+
spec.description = 'An updated ruby interface to the Mastodon API'
|
8
|
+
spec.homepage = 'https://github.com/tootsuite/mastodon-api'
|
9
|
+
spec.email = 'erickrz@riseup.net'
|
10
|
+
spec.authors = ['erick']
|
11
|
+
spec.summary = spec.description
|
12
|
+
spec.licenses = %w(MIT)
|
13
|
+
spec.files = %w(mastodon.gemspec) + Dir['lib/**/*.rb']
|
14
|
+
spec.require_paths = %w(lib)
|
15
|
+
spec.version = Mastodon::Version
|
16
|
+
|
17
|
+
spec.add_dependency 'http', '~> 5.0'
|
18
|
+
spec.add_dependency 'oj', '~> 3.7'
|
19
|
+
spec.add_dependency 'addressable', '~> 2.6'
|
20
|
+
spec.add_dependency 'buftok', '~> 0'
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '> 1', '< 3'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: todon-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- erick
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-09-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: http
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: oj
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.7'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: addressable
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.6'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: buftok
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1'
|
76
|
+
- - "<"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '3'
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">"
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '1'
|
86
|
+
- - "<"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '3'
|
89
|
+
description: An updated ruby interface to the Mastodon API
|
90
|
+
email: erickrz@riseup.net
|
91
|
+
executables: []
|
92
|
+
extensions: []
|
93
|
+
extra_rdoc_files: []
|
94
|
+
files:
|
95
|
+
- lib/mastodon.rb
|
96
|
+
- lib/mastodon/access_token.rb
|
97
|
+
- lib/mastodon/account.rb
|
98
|
+
- lib/mastodon/app.rb
|
99
|
+
- lib/mastodon/base.rb
|
100
|
+
- lib/mastodon/card.rb
|
101
|
+
- lib/mastodon/client.rb
|
102
|
+
- lib/mastodon/collection.rb
|
103
|
+
- lib/mastodon/conversation.rb
|
104
|
+
- lib/mastodon/emoji.rb
|
105
|
+
- lib/mastodon/entities/app.rb
|
106
|
+
- lib/mastodon/entities/hashtag.rb
|
107
|
+
- lib/mastodon/entities/media.rb
|
108
|
+
- lib/mastodon/entities/mention.rb
|
109
|
+
- lib/mastodon/error.rb
|
110
|
+
- lib/mastodon/field.rb
|
111
|
+
- lib/mastodon/filter.rb
|
112
|
+
- lib/mastodon/hashtag.rb
|
113
|
+
- lib/mastodon/headers.rb
|
114
|
+
- lib/mastodon/instance.rb
|
115
|
+
- lib/mastodon/list.rb
|
116
|
+
- lib/mastodon/media.rb
|
117
|
+
- lib/mastodon/notification.rb
|
118
|
+
- lib/mastodon/relationship.rb
|
119
|
+
- lib/mastodon/rest/accounts.rb
|
120
|
+
- lib/mastodon/rest/api.rb
|
121
|
+
- lib/mastodon/rest/apps.rb
|
122
|
+
- lib/mastodon/rest/client.rb
|
123
|
+
- lib/mastodon/rest/conversations.rb
|
124
|
+
- lib/mastodon/rest/custom_emojis.rb
|
125
|
+
- lib/mastodon/rest/domain_blocks.rb
|
126
|
+
- lib/mastodon/rest/endorsements.rb
|
127
|
+
- lib/mastodon/rest/filters.rb
|
128
|
+
- lib/mastodon/rest/instances.rb
|
129
|
+
- lib/mastodon/rest/lists.rb
|
130
|
+
- lib/mastodon/rest/media.rb
|
131
|
+
- lib/mastodon/rest/notifications.rb
|
132
|
+
- lib/mastodon/rest/relationships.rb
|
133
|
+
- lib/mastodon/rest/reports.rb
|
134
|
+
- lib/mastodon/rest/request.rb
|
135
|
+
- lib/mastodon/rest/scheduled_statuses.rb
|
136
|
+
- lib/mastodon/rest/search.rb
|
137
|
+
- lib/mastodon/rest/statuses.rb
|
138
|
+
- lib/mastodon/rest/suggestions.rb
|
139
|
+
- lib/mastodon/rest/timelines.rb
|
140
|
+
- lib/mastodon/rest/utils.rb
|
141
|
+
- lib/mastodon/results.rb
|
142
|
+
- lib/mastodon/scheduled_status.rb
|
143
|
+
- lib/mastodon/status.rb
|
144
|
+
- lib/mastodon/streaming/client.rb
|
145
|
+
- lib/mastodon/streaming/connection.rb
|
146
|
+
- lib/mastodon/streaming/events/filters_change.rb
|
147
|
+
- lib/mastodon/streaming/events/status_delete.rb
|
148
|
+
- lib/mastodon/streaming/message_parser.rb
|
149
|
+
- lib/mastodon/streaming/response.rb
|
150
|
+
- lib/mastodon/version.rb
|
151
|
+
- mastodon.gemspec
|
152
|
+
homepage: https://github.com/tootsuite/mastodon-api
|
153
|
+
licenses:
|
154
|
+
- MIT
|
155
|
+
metadata: {}
|
156
|
+
post_install_message:
|
157
|
+
rdoc_options: []
|
158
|
+
require_paths:
|
159
|
+
- lib
|
160
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
requirements: []
|
171
|
+
rubygems_version: 3.5.11
|
172
|
+
signing_key:
|
173
|
+
specification_version: 4
|
174
|
+
summary: An updated ruby interface to the Mastodon API
|
175
|
+
test_files: []
|