crawlberg 1.2.1 → 1.4.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 +4 -4
- data/README.md +5 -0
- data/ext/crawlberg_rb/native/Cargo.lock +113 -144
- data/ext/crawlberg_rb/native/Cargo.toml +19 -2
- data/ext/crawlberg_rb/native/extconf.rb +5 -0
- data/ext/crawlberg_rb/src/lib.rs +3627 -3434
- data/lib/crawlberg/native.rb +143 -192
- data/lib/crawlberg/version.rb +3 -3
- data/lib/crawlberg.rb +2 -2
- data/sig/types.rbs +480 -473
- metadata +2 -3
- data/lib/crawlberg_rb.so +0 -0
data/lib/crawlberg/native.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# This file is auto-generated by alef — DO NOT EDIT.
|
|
2
|
-
# alef:hash:
|
|
2
|
+
# alef:hash:4c0568b31b53eb28d5e56237159cb0d1c93079e2bbae63713fbc6b85e9683aa7
|
|
3
3
|
# To regenerate: alef generate
|
|
4
|
-
# To verify freshness: alef verify
|
|
4
|
+
# To verify freshness: alef verify
|
|
5
5
|
# frozen_string_literal: true
|
|
6
6
|
|
|
7
7
|
require "json"
|
|
@@ -18,7 +18,7 @@ library_candidates = dlexts.flat_map do |dlext|
|
|
|
18
18
|
File.join(__dir__, "..", extension_name, ruby_abi, "#{extension_name}.#{dlext}"),
|
|
19
19
|
File.join(__dir__, "..", extension_name, ruby_abi, "lib#{extension_name}.#{dlext}"),
|
|
20
20
|
File.join(__dir__, "..", "#{extension_name}.#{dlext}"),
|
|
21
|
-
File.join(__dir__, "..", "lib#{extension_name}.#{dlext}")
|
|
21
|
+
File.join(__dir__, "..", "lib#{extension_name}.#{dlext}"),
|
|
22
22
|
]
|
|
23
23
|
end
|
|
24
24
|
|
|
@@ -34,7 +34,6 @@ unless native_extension
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
require native_extension
|
|
37
|
-
|
|
38
37
|
module Crawlberg
|
|
39
38
|
# Authentication configuration.
|
|
40
39
|
module AuthConfig
|
|
@@ -50,14 +49,10 @@ module Crawlberg
|
|
|
50
49
|
def self.from_hash(hash)
|
|
51
50
|
discriminator = hash[:type] || hash["type"]
|
|
52
51
|
case discriminator
|
|
53
|
-
when "basic"
|
|
54
|
-
|
|
55
|
-
when "
|
|
56
|
-
|
|
57
|
-
when "header"
|
|
58
|
-
AuthConfigHeader.from_hash(hash)
|
|
59
|
-
else
|
|
60
|
-
raise "Unknown discriminator: #{discriminator}"
|
|
52
|
+
when "basic" then AuthConfigBasic.from_hash(hash)
|
|
53
|
+
when "bearer" then AuthConfigBearer.from_hash(hash)
|
|
54
|
+
when "header" then AuthConfigHeader.from_hash(hash)
|
|
55
|
+
else raise "Unknown discriminator: #{discriminator}"
|
|
61
56
|
end
|
|
62
57
|
end
|
|
63
58
|
end
|
|
@@ -68,12 +63,10 @@ module Crawlberg
|
|
|
68
63
|
|
|
69
64
|
# Username sent in the `Authorization: Basic` header.
|
|
70
65
|
sig { returns(String) }
|
|
71
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
72
|
-
def username = super
|
|
66
|
+
def username = super # rubocop:disable Lint/UselessMethodDefinition
|
|
73
67
|
# Password sent in the `Authorization: Basic` header.
|
|
74
68
|
sig { returns(String) }
|
|
75
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
76
|
-
def password = super
|
|
69
|
+
def password = super # rubocop:disable Lint/UselessMethodDefinition
|
|
77
70
|
sig { returns(T::Boolean) }
|
|
78
71
|
def basic? = true
|
|
79
72
|
sig { returns(T::Boolean) }
|
|
@@ -94,8 +87,7 @@ module Crawlberg
|
|
|
94
87
|
|
|
95
88
|
# Token sent in the `Authorization: Bearer` header.
|
|
96
89
|
sig { returns(String) }
|
|
97
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
98
|
-
def token = super
|
|
90
|
+
def token = super # rubocop:disable Lint/UselessMethodDefinition
|
|
99
91
|
sig { returns(T::Boolean) }
|
|
100
92
|
def basic? = false
|
|
101
93
|
sig { returns(T::Boolean) }
|
|
@@ -116,12 +108,10 @@ module Crawlberg
|
|
|
116
108
|
|
|
117
109
|
# HTTP header name to set on each request.
|
|
118
110
|
sig { returns(String) }
|
|
119
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
120
|
-
def name = super
|
|
111
|
+
def name = super # rubocop:disable Lint/UselessMethodDefinition
|
|
121
112
|
# HTTP header value to send.
|
|
122
113
|
sig { returns(String) }
|
|
123
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
124
|
-
def value = super
|
|
114
|
+
def value = super # rubocop:disable Lint/UselessMethodDefinition
|
|
125
115
|
sig { returns(T::Boolean) }
|
|
126
116
|
def basic? = false
|
|
127
117
|
sig { returns(T::Boolean) }
|
|
@@ -157,14 +147,10 @@ module Crawlberg
|
|
|
157
147
|
def self.from_hash(hash)
|
|
158
148
|
discriminator = hash[:type] || hash["type"]
|
|
159
149
|
case discriminator
|
|
160
|
-
when "page"
|
|
161
|
-
|
|
162
|
-
when "
|
|
163
|
-
|
|
164
|
-
when "complete"
|
|
165
|
-
CrawlEventComplete.from_hash(hash)
|
|
166
|
-
else
|
|
167
|
-
raise "Unknown discriminator: #{discriminator}"
|
|
150
|
+
when "page" then CrawlEventPage.from_hash(hash)
|
|
151
|
+
when "error" then CrawlEventError.from_hash(hash)
|
|
152
|
+
when "complete" then CrawlEventComplete.from_hash(hash)
|
|
153
|
+
else raise "Unknown discriminator: #{discriminator}"
|
|
168
154
|
end
|
|
169
155
|
end
|
|
170
156
|
end
|
|
@@ -175,8 +161,7 @@ module Crawlberg
|
|
|
175
161
|
|
|
176
162
|
# The crawled page result.
|
|
177
163
|
sig { returns(CrawlPageResult) }
|
|
178
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
179
|
-
def result = super
|
|
164
|
+
def result = super # rubocop:disable Lint/UselessMethodDefinition
|
|
180
165
|
sig { returns(T::Boolean) }
|
|
181
166
|
def page? = true
|
|
182
167
|
sig { returns(T::Boolean) }
|
|
@@ -197,12 +182,10 @@ module Crawlberg
|
|
|
197
182
|
|
|
198
183
|
# The URL that failed.
|
|
199
184
|
sig { returns(String) }
|
|
200
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
201
|
-
def url = super
|
|
185
|
+
def url = super # rubocop:disable Lint/UselessMethodDefinition
|
|
202
186
|
# The error message.
|
|
203
187
|
sig { returns(String) }
|
|
204
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
205
|
-
def error = super
|
|
188
|
+
def error = super # rubocop:disable Lint/UselessMethodDefinition
|
|
206
189
|
sig { returns(T::Boolean) }
|
|
207
190
|
def page? = false
|
|
208
191
|
sig { returns(T::Boolean) }
|
|
@@ -223,8 +206,7 @@ module Crawlberg
|
|
|
223
206
|
|
|
224
207
|
# Total number of pages crawled.
|
|
225
208
|
sig { returns(Integer) }
|
|
226
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
227
|
-
def pages_crawled = super
|
|
209
|
+
def pages_crawled = super # rubocop:disable Lint/UselessMethodDefinition
|
|
228
210
|
sig { returns(T::Boolean) }
|
|
229
211
|
def page? = false
|
|
230
212
|
sig { returns(T::Boolean) }
|
|
@@ -240,6 +222,108 @@ module Crawlberg
|
|
|
240
222
|
end
|
|
241
223
|
end
|
|
242
224
|
|
|
225
|
+
module Crawlberg
|
|
226
|
+
# Hostname/IP allowlist matcher for SSRF policy.
|
|
227
|
+
#
|
|
228
|
+
# Serializes as an internally-tagged object so each variant is distinguishable on the
|
|
229
|
+
# wire and round-trips losslessly:
|
|
230
|
+
#
|
|
231
|
+
# ```json
|
|
232
|
+
# {"type": "exact", "value": "api.example.com"}
|
|
233
|
+
# {"type": "suffix", "value": ".example.com"}
|
|
234
|
+
# {"type": "cidr", "value": "10.0.0.0/8"}
|
|
235
|
+
# ```
|
|
236
|
+
#
|
|
237
|
+
# A bare JSON string is still accepted on deserialization and resolves to [`Exact`],
|
|
238
|
+
# preserving configs written against the previous untagged representation.
|
|
239
|
+
#
|
|
240
|
+
# [`Exact`]: HostMatcher::Exact
|
|
241
|
+
module HostMatcher
|
|
242
|
+
extend T::Helpers
|
|
243
|
+
extend T::Sig
|
|
244
|
+
|
|
245
|
+
interface!
|
|
246
|
+
|
|
247
|
+
# Dispatch from a Hash to the appropriate variant constructor.
|
|
248
|
+
# @param hash [Hash] with discriminator field and variant-specific fields
|
|
249
|
+
# @return [variant_class] an instance of the appropriate variant
|
|
250
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.untyped) }
|
|
251
|
+
def self.from_hash(hash)
|
|
252
|
+
discriminator = hash[:type] || hash["type"]
|
|
253
|
+
case discriminator
|
|
254
|
+
when "exact" then HostMatcherExact.from_hash(hash)
|
|
255
|
+
when "suffix" then HostMatcherSuffix.from_hash(hash)
|
|
256
|
+
when "cidr" then HostMatcherCidr.from_hash(hash)
|
|
257
|
+
else raise "Unknown discriminator: #{discriminator}"
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
## Exact hostname match (case-insensitive).
|
|
262
|
+
HostMatcherExact = Data.define(:value) do
|
|
263
|
+
include HostMatcher
|
|
264
|
+
extend T::Sig
|
|
265
|
+
|
|
266
|
+
# The hostname to match.
|
|
267
|
+
sig { returns(String) }
|
|
268
|
+
def value = super # rubocop:disable Lint/UselessMethodDefinition
|
|
269
|
+
sig { returns(T::Boolean) }
|
|
270
|
+
def exact? = true
|
|
271
|
+
sig { returns(T::Boolean) }
|
|
272
|
+
def suffix? = false
|
|
273
|
+
sig { returns(T::Boolean) }
|
|
274
|
+
def cidr? = false
|
|
275
|
+
# @param hash [Hash] deserialized from the native extension
|
|
276
|
+
# @return [self]
|
|
277
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
278
|
+
def self.from_hash(hash)
|
|
279
|
+
new(value: hash[:value] || hash["value"])
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
## Suffix match: ".xberg.io" matches "api.xberg.io" and "xberg.io".
|
|
283
|
+
HostMatcherSuffix = Data.define(:value) do
|
|
284
|
+
include HostMatcher
|
|
285
|
+
extend T::Sig
|
|
286
|
+
|
|
287
|
+
# The dot-prefixed suffix to match. A leading dot is optional.
|
|
288
|
+
sig { returns(String) }
|
|
289
|
+
def value = super # rubocop:disable Lint/UselessMethodDefinition
|
|
290
|
+
sig { returns(T::Boolean) }
|
|
291
|
+
def exact? = false
|
|
292
|
+
sig { returns(T::Boolean) }
|
|
293
|
+
def suffix? = true
|
|
294
|
+
sig { returns(T::Boolean) }
|
|
295
|
+
def cidr? = false
|
|
296
|
+
# @param hash [Hash] deserialized from the native extension
|
|
297
|
+
# @return [self]
|
|
298
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
299
|
+
def self.from_hash(hash)
|
|
300
|
+
new(value: hash[:value] || hash["value"])
|
|
301
|
+
end
|
|
302
|
+
end
|
|
303
|
+
## CIDR match: "10.0.0.0/8" matches IP addresses in that range.
|
|
304
|
+
HostMatcherCidr = Data.define(:value) do
|
|
305
|
+
include HostMatcher
|
|
306
|
+
extend T::Sig
|
|
307
|
+
|
|
308
|
+
# The CIDR block. Validated when built through [`HostMatcher::cidr`] or
|
|
309
|
+
# deserialization.
|
|
310
|
+
sig { returns(String) }
|
|
311
|
+
def value = super # rubocop:disable Lint/UselessMethodDefinition
|
|
312
|
+
sig { returns(T::Boolean) }
|
|
313
|
+
def exact? = false
|
|
314
|
+
sig { returns(T::Boolean) }
|
|
315
|
+
def suffix? = false
|
|
316
|
+
sig { returns(T::Boolean) }
|
|
317
|
+
def cidr? = true
|
|
318
|
+
# @param hash [Hash] deserialized from the native extension
|
|
319
|
+
# @return [self]
|
|
320
|
+
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
321
|
+
def self.from_hash(hash)
|
|
322
|
+
new(value: hash[:value] || hash["value"])
|
|
323
|
+
end
|
|
324
|
+
end
|
|
325
|
+
end
|
|
326
|
+
|
|
243
327
|
module Crawlberg
|
|
244
328
|
# A single page interaction action.
|
|
245
329
|
#
|
|
@@ -258,24 +342,15 @@ module Crawlberg
|
|
|
258
342
|
def self.from_hash(hash)
|
|
259
343
|
discriminator = hash[:type] || hash["type"]
|
|
260
344
|
case discriminator
|
|
261
|
-
when "click"
|
|
262
|
-
|
|
263
|
-
when "
|
|
264
|
-
|
|
265
|
-
when "
|
|
266
|
-
|
|
267
|
-
when "
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
PageActionWait.from_hash(hash)
|
|
271
|
-
when "screenshot"
|
|
272
|
-
PageActionScreenshot.from_hash(hash)
|
|
273
|
-
when "executeJs"
|
|
274
|
-
PageActionExecuteJs.from_hash(hash)
|
|
275
|
-
when "scrape"
|
|
276
|
-
PageActionScrape.from_hash(hash)
|
|
277
|
-
else
|
|
278
|
-
raise "Unknown discriminator: #{discriminator}"
|
|
345
|
+
when "click" then PageActionClick.from_hash(hash)
|
|
346
|
+
when "type" then PageActionTypeText.from_hash(hash)
|
|
347
|
+
when "press" then PageActionPress.from_hash(hash)
|
|
348
|
+
when "scroll" then PageActionScroll.from_hash(hash)
|
|
349
|
+
when "wait" then PageActionWait.from_hash(hash)
|
|
350
|
+
when "screenshot" then PageActionScreenshot.from_hash(hash)
|
|
351
|
+
when "executeJs" then PageActionExecuteJs.from_hash(hash)
|
|
352
|
+
when "scrape" then PageActionScrape.from_hash(hash)
|
|
353
|
+
else raise "Unknown discriminator: #{discriminator}"
|
|
279
354
|
end
|
|
280
355
|
end
|
|
281
356
|
end
|
|
@@ -286,8 +361,7 @@ module Crawlberg
|
|
|
286
361
|
|
|
287
362
|
# CSS selector for the element to click.
|
|
288
363
|
sig { returns(String) }
|
|
289
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
290
|
-
def selector = super
|
|
364
|
+
def selector = super # rubocop:disable Lint/UselessMethodDefinition
|
|
291
365
|
sig { returns(T::Boolean) }
|
|
292
366
|
def click? = true
|
|
293
367
|
sig { returns(T::Boolean) }
|
|
@@ -318,12 +392,10 @@ module Crawlberg
|
|
|
318
392
|
|
|
319
393
|
# CSS selector for the input element.
|
|
320
394
|
sig { returns(String) }
|
|
321
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
322
|
-
def selector = super
|
|
395
|
+
def selector = super # rubocop:disable Lint/UselessMethodDefinition
|
|
323
396
|
# Text to type into the element.
|
|
324
397
|
sig { returns(String) }
|
|
325
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
326
|
-
def text = super
|
|
398
|
+
def text = super # rubocop:disable Lint/UselessMethodDefinition
|
|
327
399
|
sig { returns(T::Boolean) }
|
|
328
400
|
def click? = false
|
|
329
401
|
sig { returns(T::Boolean) }
|
|
@@ -354,8 +426,7 @@ module Crawlberg
|
|
|
354
426
|
|
|
355
427
|
# Key name to press.
|
|
356
428
|
sig { returns(String) }
|
|
357
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
358
|
-
def key = super
|
|
429
|
+
def key = super # rubocop:disable Lint/UselessMethodDefinition
|
|
359
430
|
sig { returns(T::Boolean) }
|
|
360
431
|
def click? = false
|
|
361
432
|
sig { returns(T::Boolean) }
|
|
@@ -386,16 +457,13 @@ module Crawlberg
|
|
|
386
457
|
|
|
387
458
|
# Direction to scroll.
|
|
388
459
|
sig { returns(ScrollDirection) }
|
|
389
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
390
|
-
def direction = super
|
|
460
|
+
def direction = super # rubocop:disable Lint/UselessMethodDefinition
|
|
391
461
|
# Optional CSS selector for a scrollable element. Scrolls the page if absent.
|
|
392
462
|
sig { returns(T.nilable(String)) }
|
|
393
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
394
|
-
def selector = super
|
|
463
|
+
def selector = super # rubocop:disable Lint/UselessMethodDefinition
|
|
395
464
|
# Optional pixel amount to scroll. Uses a default if absent.
|
|
396
465
|
sig { returns(T.nilable(Integer)) }
|
|
397
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
398
|
-
def amount = super
|
|
466
|
+
def amount = super # rubocop:disable Lint/UselessMethodDefinition
|
|
399
467
|
sig { returns(T::Boolean) }
|
|
400
468
|
def click? = false
|
|
401
469
|
sig { returns(T::Boolean) }
|
|
@@ -416,11 +484,7 @@ module Crawlberg
|
|
|
416
484
|
# @return [self]
|
|
417
485
|
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
418
486
|
def self.from_hash(hash)
|
|
419
|
-
new(
|
|
420
|
-
direction: hash[:direction] || hash["direction"],
|
|
421
|
-
selector: hash[:selector] || hash["selector"],
|
|
422
|
-
amount: hash[:amount] || hash["amount"]
|
|
423
|
-
)
|
|
487
|
+
new(direction: hash[:direction] || hash["direction"], selector: hash[:selector] || hash["selector"], amount: hash[:amount] || hash["amount"])
|
|
424
488
|
end
|
|
425
489
|
end
|
|
426
490
|
## Wait for a duration or for an element to appear.
|
|
@@ -430,12 +494,10 @@ module Crawlberg
|
|
|
430
494
|
|
|
431
495
|
# Milliseconds to wait. Ignored if `selector` is provided.
|
|
432
496
|
sig { returns(T.nilable(Integer)) }
|
|
433
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
434
|
-
def milliseconds = super
|
|
497
|
+
def milliseconds = super # rubocop:disable Lint/UselessMethodDefinition
|
|
435
498
|
# CSS selector to wait for.
|
|
436
499
|
sig { returns(T.nilable(String)) }
|
|
437
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
438
|
-
def selector = super
|
|
500
|
+
def selector = super # rubocop:disable Lint/UselessMethodDefinition
|
|
439
501
|
sig { returns(T::Boolean) }
|
|
440
502
|
def click? = false
|
|
441
503
|
sig { returns(T::Boolean) }
|
|
@@ -470,8 +532,7 @@ module Crawlberg
|
|
|
470
532
|
# `full_page` (snake_case) alias so language bindings and fixtures can
|
|
471
533
|
# use either convention without error.
|
|
472
534
|
sig { returns(T.nilable(T::Boolean)) }
|
|
473
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
474
|
-
def full_page = super
|
|
535
|
+
def full_page = super # rubocop:disable Lint/UselessMethodDefinition
|
|
475
536
|
sig { returns(T::Boolean) }
|
|
476
537
|
def click? = false
|
|
477
538
|
sig { returns(T::Boolean) }
|
|
@@ -507,8 +568,7 @@ module Crawlberg
|
|
|
507
568
|
|
|
508
569
|
# JavaScript source code to execute. Max 1 MB.
|
|
509
570
|
sig { returns(String) }
|
|
510
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
511
|
-
def script = super
|
|
571
|
+
def script = super # rubocop:disable Lint/UselessMethodDefinition
|
|
512
572
|
sig { returns(T::Boolean) }
|
|
513
573
|
def click? = false
|
|
514
574
|
sig { returns(T::Boolean) }
|
|
@@ -561,112 +621,3 @@ module Crawlberg
|
|
|
561
621
|
end
|
|
562
622
|
end
|
|
563
623
|
end
|
|
564
|
-
|
|
565
|
-
module Crawlberg
|
|
566
|
-
# Hostname/IP allowlist matcher for SSRF policy.
|
|
567
|
-
#
|
|
568
|
-
# Serializes as an internally-tagged object so each variant is distinguishable on the
|
|
569
|
-
# wire and round-trips losslessly:
|
|
570
|
-
#
|
|
571
|
-
# ```json
|
|
572
|
-
# {"type": "exact", "value": "api.example.com"}
|
|
573
|
-
# {"type": "suffix", "value": ".example.com"}
|
|
574
|
-
# {"type": "cidr", "value": "10.0.0.0/8"}
|
|
575
|
-
# ```
|
|
576
|
-
#
|
|
577
|
-
# A bare JSON string is still accepted on deserialization and resolves to [`Exact`],
|
|
578
|
-
# preserving configs written against the previous untagged representation.
|
|
579
|
-
#
|
|
580
|
-
# [`Exact`]: HostMatcher::Exact
|
|
581
|
-
module HostMatcher
|
|
582
|
-
extend T::Helpers
|
|
583
|
-
extend T::Sig
|
|
584
|
-
|
|
585
|
-
interface!
|
|
586
|
-
|
|
587
|
-
# Dispatch from a Hash to the appropriate variant constructor.
|
|
588
|
-
# @param hash [Hash] with discriminator field and variant-specific fields
|
|
589
|
-
# @return [variant_class] an instance of the appropriate variant
|
|
590
|
-
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.untyped) }
|
|
591
|
-
def self.from_hash(hash)
|
|
592
|
-
discriminator = hash[:type] || hash["type"]
|
|
593
|
-
case discriminator
|
|
594
|
-
when "exact"
|
|
595
|
-
HostMatcherExact.from_hash(hash)
|
|
596
|
-
when "suffix"
|
|
597
|
-
HostMatcherSuffix.from_hash(hash)
|
|
598
|
-
when "cidr"
|
|
599
|
-
HostMatcherCidr.from_hash(hash)
|
|
600
|
-
else
|
|
601
|
-
raise "Unknown discriminator: #{discriminator}"
|
|
602
|
-
end
|
|
603
|
-
end
|
|
604
|
-
end
|
|
605
|
-
## Exact hostname match (case-insensitive).
|
|
606
|
-
HostMatcherExact = Data.define(:value) do
|
|
607
|
-
include HostMatcher
|
|
608
|
-
extend T::Sig
|
|
609
|
-
|
|
610
|
-
# The hostname to match.
|
|
611
|
-
sig { returns(String) }
|
|
612
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
613
|
-
def value = super
|
|
614
|
-
sig { returns(T::Boolean) }
|
|
615
|
-
def exact? = true
|
|
616
|
-
sig { returns(T::Boolean) }
|
|
617
|
-
def suffix? = false
|
|
618
|
-
sig { returns(T::Boolean) }
|
|
619
|
-
def cidr? = false
|
|
620
|
-
# @param hash [Hash] deserialized from the native extension
|
|
621
|
-
# @return [self]
|
|
622
|
-
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
623
|
-
def self.from_hash(hash)
|
|
624
|
-
new(value: hash[:value] || hash["value"])
|
|
625
|
-
end
|
|
626
|
-
end
|
|
627
|
-
## Suffix match: ".xberg.io" matches "api.xberg.io" and "xberg.io".
|
|
628
|
-
HostMatcherSuffix = Data.define(:value) do
|
|
629
|
-
include HostMatcher
|
|
630
|
-
extend T::Sig
|
|
631
|
-
|
|
632
|
-
# The dot-prefixed suffix to match. A leading dot is optional.
|
|
633
|
-
sig { returns(String) }
|
|
634
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
635
|
-
def value = super
|
|
636
|
-
sig { returns(T::Boolean) }
|
|
637
|
-
def exact? = false
|
|
638
|
-
sig { returns(T::Boolean) }
|
|
639
|
-
def suffix? = true
|
|
640
|
-
sig { returns(T::Boolean) }
|
|
641
|
-
def cidr? = false
|
|
642
|
-
# @param hash [Hash] deserialized from the native extension
|
|
643
|
-
# @return [self]
|
|
644
|
-
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
645
|
-
def self.from_hash(hash)
|
|
646
|
-
new(value: hash[:value] || hash["value"])
|
|
647
|
-
end
|
|
648
|
-
end
|
|
649
|
-
## CIDR match: "10.0.0.0/8" matches IP addresses in that range.
|
|
650
|
-
HostMatcherCidr = Data.define(:value) do
|
|
651
|
-
include HostMatcher
|
|
652
|
-
extend T::Sig
|
|
653
|
-
|
|
654
|
-
# The CIDR block. Validated when built through [`HostMatcher::cidr`] or
|
|
655
|
-
# deserialization.
|
|
656
|
-
sig { returns(String) }
|
|
657
|
-
# rubocop:disable Lint/UselessMethodDefinition
|
|
658
|
-
def value = super
|
|
659
|
-
sig { returns(T::Boolean) }
|
|
660
|
-
def exact? = false
|
|
661
|
-
sig { returns(T::Boolean) }
|
|
662
|
-
def suffix? = false
|
|
663
|
-
sig { returns(T::Boolean) }
|
|
664
|
-
def cidr? = true
|
|
665
|
-
# @param hash [Hash] deserialized from the native extension
|
|
666
|
-
# @return [self]
|
|
667
|
-
sig { params(hash: T::Hash[T.untyped, T.untyped]).returns(T.attached_class) }
|
|
668
|
-
def self.from_hash(hash)
|
|
669
|
-
new(value: hash[:value] || hash["value"])
|
|
670
|
-
end
|
|
671
|
-
end
|
|
672
|
-
end
|
data/lib/crawlberg/version.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# This file is auto-generated by alef — DO NOT EDIT.
|
|
2
|
-
# alef:hash:
|
|
2
|
+
# alef:hash:0a9a0a6f7c1b865f2c375eef53bab2695c7dbf595519ca3bd7f5d258c2936ef7
|
|
3
3
|
# To regenerate: alef generate
|
|
4
|
-
# To verify freshness: alef verify
|
|
4
|
+
# To verify freshness: alef verify
|
|
5
5
|
# frozen_string_literal: true
|
|
6
6
|
|
|
7
7
|
module Crawlberg
|
|
8
8
|
## The version string for this package.
|
|
9
|
-
VERSION = "1.
|
|
9
|
+
VERSION = "1.4.0"
|
|
10
10
|
end
|
data/lib/crawlberg.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# This file is auto-generated by alef — DO NOT EDIT.
|
|
2
|
-
# alef:hash:
|
|
2
|
+
# alef:hash:72251b3aa02bf769e473206839c833cf616e70a8dd38735f5ff3a3a2849e8c0a
|
|
3
3
|
# To regenerate: alef generate
|
|
4
|
-
# To verify freshness: alef verify
|
|
4
|
+
# To verify freshness: alef verify
|
|
5
5
|
# frozen_string_literal: true
|
|
6
6
|
|
|
7
7
|
require_relative "crawlberg/version"
|