screenshotcenter 1.0.0 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ed56218652a0790a0d5881620b32144b126e7df27f10a3f4d77a41c6557c864
4
- data.tar.gz: 3a297128e05c9c57377bfa5215689daa0ca96b416dc88426592a1ee244a2d4cd
3
+ metadata.gz: 4452b3e387b334ebc108f922d9863ab210fd38bcb604963748e52a6c30a79744
4
+ data.tar.gz: a6fbf5c01b4c306c6194c4965a108497a0ebae65be5e13321b58a7eb06c5be83
5
5
  SHA512:
6
- metadata.gz: 563aacf957e46b95c59bbbf6ec7d7003a15d7725c787a095ee7759585977f849525b906335115c42ab26821c6d2259c1472be7ed0bbfde94bbfffda191544b75
7
- data.tar.gz: e8a040ff58b5bc2e7841494060a44bc5d941c9a3234c185b9637c9a0158720692d1a498a920ed2f8aedcd3a57b00c0325fe415a23988421b772d357e3b4551ee
6
+ metadata.gz: 265c94ef09f83afa6e9f109199eba5d26be775f550e6c8a9b7d1f43fa06f7ff4ccd69af096b5b09c5577c324b560e319ce530deef888fc6fa0db4fc5e14ffae3
7
+ data.tar.gz: aaf3bef386e0bc93b3fe404fd221a7f88133617bfacab495bc41a1b433ae59a030fddf1653293eb799aa3a89c12241ab0d6f73aa1db654aee01ad604c8261d93
@@ -15,7 +15,7 @@ module ScreenshotCenter
15
15
  class Client
16
16
  DEFAULT_BASE_URL = "https://api.screenshotcenter.com/api/v1"
17
17
 
18
- attr_reader :screenshot, :batch, :account
18
+ attr_reader :screenshot, :batch, :account, :crawl
19
19
 
20
20
  # @param api_key [String] Your ScreenshotCenter API key (required).
21
21
  # @param base_url [String] Override the base URL (optional).
@@ -33,6 +33,7 @@ module ScreenshotCenter
33
33
  @screenshot = ScreenshotNamespace.new(self)
34
34
  @batch = BatchNamespace.new(self)
35
35
  @account = AccountNamespace.new(self)
36
+ @crawl = CrawlNamespace.new(self)
36
37
  end
37
38
 
38
39
  # Poll a screenshot until it reaches +finished+ or +error+.
@@ -305,6 +306,48 @@ module ScreenshotCenter
305
306
  end
306
307
  end
307
308
 
309
+ class CrawlNamespace
310
+ def initialize(client)
311
+ @client = client
312
+ end
313
+
314
+ # @param url [String] starting URL (required)
315
+ # @param domain [String] domain to crawl (required)
316
+ # @param max_urls [Integer] maximum URLs to crawl (required)
317
+ def create(url, domain, max_urls, **params)
318
+ raise ArgumentError, '"url" is required' if url.nil? || url.empty?
319
+ raise ArgumentError, '"domain" is required' if domain.nil? || domain.empty?
320
+ raise ArgumentError, '"max_urls" is required' if max_urls.nil?
321
+
322
+ body = JSON.generate({ url: url, domain: domain, max_urls: max_urls }.merge(params))
323
+ @client._post("/crawl/create", body, "application/json")
324
+ end
325
+
326
+ def info(id)
327
+ @client._get("/crawl/info", { id: id })
328
+ end
329
+
330
+ def list(**params)
331
+ @client._get("/crawl/list", params)
332
+ end
333
+
334
+ def cancel(id)
335
+ body = JSON.generate({ id: id })
336
+ @client._post("/crawl/cancel", body, "application/json")
337
+ end
338
+
339
+ def wait_for(id, interval: 2.0, timeout: 120.0)
340
+ deadline = Time.now + timeout
341
+ loop do
342
+ c = info(id)
343
+ return c if %w[finished error].include?(c["status"])
344
+ raise TimeoutError.new(id, (timeout * 1000).to_i) if Time.now + interval > deadline
345
+
346
+ sleep interval
347
+ end
348
+ end
349
+ end
350
+
308
351
  class AccountNamespace
309
352
  def initialize(client)
310
353
  @client = client
@@ -1,3 +1,3 @@
1
1
  module ScreenshotCenter
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: screenshotcenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ScreenshotCenter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-03-14 00:00:00.000000000 Z
11
+ date: 2026-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest