ratproto 0.3.3 → 0.3.4
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 +4 -0
- data/lib/ratproto/commands/stream.rb +26 -7
- 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: c5fee431ed4b84e739b1ff36768bfb1db007dd1457d63dfd1ba5279c92b66c00
|
|
4
|
+
data.tar.gz: 260c01a4b45629e2c55026404ad5bbbc6fe9e93a22647cba85d4897b11a7ed81
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ff763fe7c82d4a645de4228bf909e362b33efd98094390451bcf99b6b64c9ce165f83f17c4325746f7f4c73a076d3824944b5422c871f6bf25fdc89331f1a7a3
|
|
7
|
+
data.tar.gz: 855c076aa6553f04635f5275e2b94bef28bd78d91f816b9446cad9f8c5d305719dcb4dbdc85c986d9b736d3355d3cc4d2faec59425c2eca9f93b821c7cbf906e
|
data/CHANGELOG.md
CHANGED
|
@@ -17,13 +17,8 @@ module RatProto
|
|
|
17
17
|
|
|
18
18
|
option ['-j', '--jetstream'], :flag, 'use a Jetstream source'
|
|
19
19
|
|
|
20
|
-
option
|
|
21
|
-
['-r', '--cursor'], 'CURSOR',
|
|
20
|
+
option ['-r', '--cursor'], 'CURSOR',
|
|
22
21
|
'start from a given cursor (pass 0 to read from the beginning of the playback window)'
|
|
23
|
-
) do |value|
|
|
24
|
-
raise ArgumentError, 'must be a decimal integer' unless value =~ /\A\d+\z/
|
|
25
|
-
value.to_i
|
|
26
|
-
end
|
|
27
22
|
|
|
28
23
|
option ['-d', '--did'], 'DID[,DID...]', 'filter events by DID (comma-separated or repeated)',
|
|
29
24
|
multivalued: true, attribute_name: :did_values
|
|
@@ -48,6 +43,7 @@ module RatProto
|
|
|
48
43
|
require 'skyfall'
|
|
49
44
|
|
|
50
45
|
prepare_filters
|
|
46
|
+
validate_cursor
|
|
51
47
|
|
|
52
48
|
@sky = build_stream
|
|
53
49
|
configure_interrupt_handler
|
|
@@ -97,6 +93,29 @@ module RatProto
|
|
|
97
93
|
@operations = (@operations.length > 0) ? @operations.map { |operation| validate_operation(operation) } : nil
|
|
98
94
|
end
|
|
99
95
|
|
|
96
|
+
def validate_cursor
|
|
97
|
+
return if cursor.nil?
|
|
98
|
+
|
|
99
|
+
if cursor.start_with?('-')
|
|
100
|
+
if !jetstream?
|
|
101
|
+
signal_usage_error("time offset cursors are only supported with Jetstream right now")
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
if cursor =~ /\A\-([0-9]+(\.[0-9]+)?)([hms])\z/i
|
|
105
|
+
amount, unit = $1, $3.downcase
|
|
106
|
+
|
|
107
|
+
multiplier = { 'h' => 3600, 'm' => 60, 's' => 1 }[unit]
|
|
108
|
+
@cursor = (Time.now.to_f - amount.to_f * multiplier) * 1_000_000
|
|
109
|
+
else
|
|
110
|
+
signal_usage_error("invalid time offset specifier: #{cursor}")
|
|
111
|
+
end
|
|
112
|
+
elsif cursor =~ /\A[0-9]+\z/
|
|
113
|
+
@cursor = cursor.to_i
|
|
114
|
+
else
|
|
115
|
+
signal_usage_error("cursor must be an integer number or an offset specifier")
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
100
119
|
def validate_operation(operation)
|
|
101
120
|
if OPERATION_TYPES.include?(operation)
|
|
102
121
|
operation.to_sym
|
|
@@ -108,7 +127,7 @@ module RatProto
|
|
|
108
127
|
def build_stream
|
|
109
128
|
if jetstream?
|
|
110
129
|
options = {}
|
|
111
|
-
options[:cursor] = cursor if cursor
|
|
130
|
+
options[:cursor] = @cursor if @cursor
|
|
112
131
|
|
|
113
132
|
# pass DID/collection filters to Jetstream to filter events server-side
|
|
114
133
|
options[:wanted_dids] = @dids if @dids
|
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: 0.3.
|
|
4
|
+
version: 0.3.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kuba Suder
|
|
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
133
133
|
- !ruby/object:Gem::Version
|
|
134
134
|
version: '0'
|
|
135
135
|
requirements: []
|
|
136
|
-
rubygems_version:
|
|
136
|
+
rubygems_version: 4.0.18
|
|
137
137
|
specification_version: 4
|
|
138
138
|
summary: Ruby CLI tool for accessing Bluesky API / ATProto
|
|
139
139
|
test_files: []
|