ratproto 0.1 → 0.1.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/CHANGELOG.md +11 -0
- data/exe/rat +63 -8
- data/lib/ratproto/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: 7897b08049db9ed366fe7bace08dc7fba37089accf140df8a266071c1d30c676
|
|
4
|
+
data.tar.gz: e8a7d6779e21941e3fb02a6c54683a22bb3d8bd65be4bef10d64507c86f193fe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 847b25a95b46ad7b07898790205e5e87761746b96c9488554548f27b74052f9086374e896a12ba8562d55f3560a0139d91ebf67eac495161bec27590ac5e4b67
|
|
7
|
+
data.tar.gz: cdb37c2c7d782977c75207ad17cfed669e183beb73b6fb71f8fe9cc135516879aac8966814afd559236be1d1ad58907e822b296069c9a1f059fd5916cc3d17a3
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## [0.1.2] - 2026-05-24
|
|
2
|
+
|
|
3
|
+
- `resolve`: added `-d` and `-p` options to print only the DID or the PDS endpoint respectively
|
|
4
|
+
- `stream`: print the last received cursor when stopped
|
|
5
|
+
- `stream`: accept also handles instead of DIDs for the `-d` argument
|
|
6
|
+
- lazy-load `skyfall` only in `stream`
|
|
7
|
+
|
|
8
|
+
## [0.1.1] - 2026-01-03
|
|
9
|
+
|
|
10
|
+
- fixed rat emoji in the help output :D
|
|
11
|
+
|
|
1
12
|
## [0.1] - 2026-01-03
|
|
2
13
|
|
|
3
14
|
- cleaned up / rewritten the code
|
data/exe/rat
CHANGED
|
@@ -6,7 +6,6 @@ require 'didkit'
|
|
|
6
6
|
require 'json'
|
|
7
7
|
require 'minisky'
|
|
8
8
|
require 'optparse'
|
|
9
|
-
require 'skyfall'
|
|
10
9
|
require 'time'
|
|
11
10
|
require 'uri'
|
|
12
11
|
|
|
@@ -14,10 +13,11 @@ require 'ratproto/version'
|
|
|
14
13
|
|
|
15
14
|
DID_REGEXP = /\Adid:[a-z]+:[a-zA-Z0-9.\-_]+\z/
|
|
16
15
|
NSID_REGEXP = /\A[a-z0-9]+(\.[a-z0-9]+)+\z/
|
|
16
|
+
HANDLE_REGEXP = /\A[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)+\z/
|
|
17
17
|
|
|
18
18
|
def print_help
|
|
19
19
|
puts <<~HELP
|
|
20
|
-
rat #{RatProto::VERSION}
|
|
20
|
+
rat #{RatProto::VERSION} 🐀
|
|
21
21
|
|
|
22
22
|
Usage:
|
|
23
23
|
rat fetch at://uri
|
|
@@ -46,8 +46,16 @@ def abort_with_error(message)
|
|
|
46
46
|
exit 1
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
def
|
|
50
|
-
|
|
49
|
+
def check_stream_did(did)
|
|
50
|
+
if did =~ DID_REGEXP
|
|
51
|
+
did
|
|
52
|
+
elsif did =~ HANDLE_REGEXP
|
|
53
|
+
if resolved_did = DID.resolve_handle(did)
|
|
54
|
+
resolved_did.to_s
|
|
55
|
+
else
|
|
56
|
+
abort_with_error "Error: couldn't resolve handle @#{did}"
|
|
57
|
+
end
|
|
58
|
+
else
|
|
51
59
|
abort_with_error "Error: #{did.inspect} is not a valid DID"
|
|
52
60
|
end
|
|
53
61
|
end
|
|
@@ -97,11 +105,49 @@ def run_fetch(args)
|
|
|
97
105
|
puts JSON.pretty_generate(response['value'])
|
|
98
106
|
end
|
|
99
107
|
|
|
108
|
+
def parse_resolve_options(args)
|
|
109
|
+
options = {}
|
|
110
|
+
|
|
111
|
+
parser = OptionParser.new do |opts|
|
|
112
|
+
opts.banner = "Usage: #{$PROGRAM_NAME} resolve <did>|<handle> [options]"
|
|
113
|
+
|
|
114
|
+
opts.on('-d', '--did', 'Print only the DID resolved from the handle') do
|
|
115
|
+
options[:only_did] = true
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
opts.on('-p', '--pds', 'Print only the PDS endpoint') do
|
|
119
|
+
options[:only_pds] = true
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
opts.on('-h', '--help', 'Show resolve-specific help') do
|
|
123
|
+
puts opts
|
|
124
|
+
exit
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
remaining = []
|
|
129
|
+
|
|
130
|
+
begin
|
|
131
|
+
parser.order!(args) { |other| remaining << other }
|
|
132
|
+
rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e
|
|
133
|
+
puts "Error: #{e.message}"
|
|
134
|
+
puts parser
|
|
135
|
+
exit 1
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
if options[:only_did] && options[:only_pds]
|
|
139
|
+
abort_with_error "--pds and --did options cannot be used together"
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
[options, remaining]
|
|
143
|
+
end
|
|
144
|
+
|
|
100
145
|
def run_resolve(args)
|
|
101
|
-
|
|
146
|
+
options, arguments = parse_resolve_options(args)
|
|
147
|
+
target = arguments.shift
|
|
102
148
|
|
|
103
149
|
if target.nil?
|
|
104
|
-
abort_with_error "Usage: #{$PROGRAM_NAME} resolve <did>|<handle>"
|
|
150
|
+
abort_with_error "Usage: #{$PROGRAM_NAME} resolve <did>|<handle> [options]"
|
|
105
151
|
end
|
|
106
152
|
|
|
107
153
|
if !args.empty?
|
|
@@ -114,7 +160,13 @@ def run_resolve(args)
|
|
|
114
160
|
abort_with_error "Couldn't resolve #{target}"
|
|
115
161
|
end
|
|
116
162
|
|
|
117
|
-
|
|
163
|
+
if options[:only_did]
|
|
164
|
+
puts did
|
|
165
|
+
elsif options[:only_pds]
|
|
166
|
+
puts did.document.pds_endpoint
|
|
167
|
+
else
|
|
168
|
+
puts JSON.pretty_generate(did.document.json)
|
|
169
|
+
end
|
|
118
170
|
rescue StandardError => e
|
|
119
171
|
abort_with_error "Error resolving #{target.inspect}: #{e.class}: #{e.message}"
|
|
120
172
|
end
|
|
@@ -192,7 +244,7 @@ def run_stream(args)
|
|
|
192
244
|
end
|
|
193
245
|
|
|
194
246
|
if options[:dids]
|
|
195
|
-
options[:dids].
|
|
247
|
+
options[:dids] = options[:dids].map { |did| check_stream_did(did) }
|
|
196
248
|
end
|
|
197
249
|
|
|
198
250
|
if options[:collections]
|
|
@@ -240,6 +292,8 @@ def run_stream(args)
|
|
|
240
292
|
end
|
|
241
293
|
|
|
242
294
|
sky.connect
|
|
295
|
+
|
|
296
|
+
puts "Stopped stream at cursor #{sky.cursor}"
|
|
243
297
|
end
|
|
244
298
|
|
|
245
299
|
if ARGV.empty?
|
|
@@ -259,6 +313,7 @@ when 'fetch'
|
|
|
259
313
|
when 'resolve'
|
|
260
314
|
run_resolve(ARGV)
|
|
261
315
|
when 'stream'
|
|
316
|
+
require 'skyfall'
|
|
262
317
|
run_stream(ARGV)
|
|
263
318
|
else
|
|
264
319
|
abort_with_error "Error: unknown command: #{cmd}"
|
data/lib/ratproto/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ratproto
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kuba Suder
|
|
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
104
104
|
- !ruby/object:Gem::Version
|
|
105
105
|
version: '0'
|
|
106
106
|
requirements: []
|
|
107
|
-
rubygems_version: 4.0.
|
|
107
|
+
rubygems_version: 4.0.10
|
|
108
108
|
specification_version: 4
|
|
109
109
|
summary: Ruby CLI tool for accessing Bluesky API / ATProto
|
|
110
110
|
test_files: []
|