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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a098c33a93bc8b33f32631f733fb3b5d3d1f3b233035d1cdbf8d397071a8d566
4
- data.tar.gz: ae846bf49bca35fa4ee7fe748e8d0a05eeaf60a44f6cd687d7a0d66f61c4254f
3
+ metadata.gz: c5fee431ed4b84e739b1ff36768bfb1db007dd1457d63dfd1ba5279c92b66c00
4
+ data.tar.gz: 260c01a4b45629e2c55026404ad5bbbc6fe9e93a22647cba85d4897b11a7ed81
5
5
  SHA512:
6
- metadata.gz: 9abf0ae89949e3e20b9f89c6b0ed9d09275a4fe55b68104c0579f6c85b6f10b7901c0dc9c884c022b8f269cf28bcfe6e07e00db9519266ab4e00bc5fab5e8b35
7
- data.tar.gz: 0dfd41610d6faf493475041b065b8e688bae795bdb14c85238945ec0498a80d9ea530e7ce9e1e8fe81d7938f106c9467d100859404925000a4e58927c60a480a
6
+ metadata.gz: ff763fe7c82d4a645de4228bf909e362b33efd98094390451bcf99b6b64c9ce165f83f17c4325746f7f4c73a076d3824944b5422c871f6bf25fdc89331f1a7a3
7
+ data.tar.gz: 855c076aa6553f04635f5275e2b94bef28bd78d91f816b9446cad9f8c5d305719dcb4dbdc85c986d9b736d3355d3cc4d2faec59425c2eca9f93b821c7cbf906e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.3.4] - 2026-09-03
2
+
3
+ - `stream`: for Jetstream sources, you can pass e.g. '-4h' as the cursor to start from 4 hours ago
4
+
1
5
  ## [0.3.3] - 2026-08-17
2
6
 
3
7
  - `stream`: added `--print-time` mode, bug fixes, unified timestamp formats
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RatProto
4
- VERSION = "0.3.3"
4
+ VERSION = "0.3.4"
5
5
  end
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.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: 3.6.9
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: []