coelacanth 0.4.1 → 0.4.3

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: 9097f36247caad8f0764313b306398e3707290eca25d5cfffc05f61e97784884
4
- data.tar.gz: 19e093800bcb9ae663e0f36a1ad18d15472ff2e76f34f6ddf65c396440aea2e0
3
+ metadata.gz: 163fc75f51d17478d0314620279c1d23f4259fbd278046629a7c9bd293bf2eec
4
+ data.tar.gz: a47846ba9bb23797a40957a376b77c4e6229b61898046b0ce910a80fc07de83b
5
5
  SHA512:
6
- metadata.gz: 32c30afcf5316814e42f2ed2f5b94efe49daecdd78b7acdf1d10d64ed2c8253a86a0a0be3b66ed1824cfbefb32c5654f3abf0fb08c41411d736281f480375400
7
- data.tar.gz: 4e6683d596d50535dd13df26d2c6c4339fe543013d37250c8e55f7605dc441aa3ed888fcf46f9550540583e3234bd52667cd28d1b9e098a18e3eb5faae354bed
6
+ metadata.gz: 9fb2695856b6eddefbaaccc853b53292dfa3fddaa3d83426ea461aba1485f808b2f5553c5f2a34c79c02185b17641e35cfddf83fc86d0676a4a6b9ed16309a34
7
+ data.tar.gz: 259a3244d4633134307d3668730ec1345ed5df1c3bfb39e07d4d44f96d3eb5324ae3b0ff6813b9fda8df3baf68eaab031594144d9728626b9540a24351ef48e0
data/CHANGELOG.md CHANGED
@@ -4,8 +4,8 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## [v0.4.1] - 2025-11-03
7
+ ## [v0.4.3] - 2025-11-05
8
8
  ### :wrench: Chores
9
- - [`41e89b7`](https://github.com/slidict/coelacanth/commit/41e89b799573f6cfaf0a12e7abc5c260f1905aec) - Bump version from 0.4.0 to 0.4.1 *(commit by [@yubele](https://github.com/yubele))*
9
+ - [`46fc62f`](https://github.com/slidict/coelacanth/commit/46fc62f1e8222fc878246a4c621ea1f5a6ceccc0) - Bump version to 0.4.3 *(commit by [@yubele](https://github.com/yubele))*
10
10
 
11
- [v0.4.1]: https://github.com/slidict/coelacanth/compare/v0.4.0...v0.4.1
11
+ [v0.4.3]: https://github.com/slidict/coelacanth/compare/v0.4.2...v0.4.3
data/README.md CHANGED
@@ -114,6 +114,7 @@ development:
114
114
  remote_client:
115
115
  ws_url: "ws://chrome:3000/chrome"
116
116
  timeout: 10
117
+ wait_for_idle_timeout: 5
117
118
  headers:
118
119
  <% if (auth = ENV["COELACANTH_REMOTE_CLIENT_AUTHORIZATION"]).to_s.strip != "" %>
119
120
  Authorization: "<%= auth %>"
@@ -124,7 +125,7 @@ development:
124
125
  ```
125
126
 
126
127
  - **Ferrum client** – Requires a running Chrome instance that exposes the DevTools protocol via WebSocket. Configure the URL,
127
- timeout, and any headers to inject.
128
+ timeout, the network idle timeout, and any headers to inject.
128
129
  - **ScreenshotOne client** – Supply an API key to offload screenshot capture to [ScreenshotOne](https://screenshotone.com/).
129
130
  - Configuration is environment-aware: set `RAILS_ENV`/`RACK_ENV` or use Rails' built-in environment handling when the gem is
130
131
  used inside a Rails project.
@@ -3,6 +3,7 @@ development: &development
3
3
  remote_client:
4
4
  ws_url: "ws://chrome:3000/chrome"
5
5
  timeout: 10 # seconds
6
+ wait_for_idle_timeout: 5 # seconds to wait before giving up on network idle
6
7
  headers:
7
8
  <% if (auth = ENV["COELACANTH_REMOTE_CLIENT_AUTHORIZATION"]).to_s.strip != "" %>
8
9
  Authorization: "<%= auth %>"
@@ -12,7 +12,7 @@ module Coelacanth::Client
12
12
 
13
13
  def get_response(url = nil)
14
14
  @status_code = remote_client.network.status
15
- remote_client.network.wait_for_idle! # might raise an error
15
+ wait_for_network_idle
16
16
  body = remote_client.body
17
17
  body
18
18
  rescue => e
@@ -21,7 +21,7 @@ module Coelacanth::Client
21
21
 
22
22
  def get_screenshot
23
23
  tempfile = Tempfile.new
24
- remote_client.network.wait_for_idle! # まずJSの完了を待つ
24
+ wait_for_network_idle
25
25
  remote_client.screenshot(path: tempfile.path, format: "png")
26
26
  File.read(tempfile.path)
27
27
  rescue => e
@@ -41,6 +41,27 @@ module Coelacanth::Client
41
41
  "#{@remote_client.class.name}(object_id=#{@remote_client.object_id})"
42
42
  end
43
43
 
44
+ def wait_for_network_idle
45
+ timeout = wait_for_idle_timeout
46
+
47
+ if timeout
48
+ remote_client.network.wait_for_idle!(timeout: timeout)
49
+ else
50
+ remote_client.network.wait_for_idle!
51
+ end
52
+ rescue ::Ferrum::TimeoutError
53
+ nil
54
+ end
55
+
56
+ def wait_for_idle_timeout
57
+ timeout = @config.read("remote_client.wait_for_idle_timeout")
58
+ return timeout if timeout
59
+
60
+ DEFAULT_WAIT_FOR_IDLE_TIMEOUT
61
+ end
62
+
63
+ DEFAULT_WAIT_FOR_IDLE_TIMEOUT = 5
64
+
44
65
  def remote_client
45
66
  return @remote_client if @remote_client
46
67
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Coelacanth
4
- VERSION = "0.4.1"
4
+ VERSION = "0.4.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coelacanth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yusuke