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 +4 -4
- data/CHANGELOG.md +3 -3
- data/README.md +2 -1
- data/config/coelacanth.yml +1 -0
- data/lib/coelacanth/client/ferrum.rb +23 -2
- data/lib/coelacanth/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 163fc75f51d17478d0314620279c1d23f4259fbd278046629a7c9bd293bf2eec
|
|
4
|
+
data.tar.gz: a47846ba9bb23797a40957a376b77c4e6229b61898046b0ce910a80fc07de83b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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.
|
|
7
|
+
## [v0.4.3] - 2025-11-05
|
|
8
8
|
### :wrench: Chores
|
|
9
|
-
- [`
|
|
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.
|
|
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.
|
data/config/coelacanth.yml
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
data/lib/coelacanth/version.rb
CHANGED