vizzly 0.2.0 → 0.2.1
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/lib/vizzly.rb +25 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0d871ec31907ae78a9790e8763340300d5b3b0860048ad3bde1d540e8de746e2
|
|
4
|
+
data.tar.gz: e03b0e7d53d526c82d813a3a9435cb3bb77a7af9450c2de5ddc03f09f7c05815
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b482c246a5e588d07548a4ffdcf8a9bf61f158510ad49238e242a8fc5a26f0eb24ff02603a3623c9414ca069a6e553248d0d1aae0bd4da2dcdb7711d97ca18c1
|
|
7
|
+
data.tar.gz: 1109017a272528539721084733f5f5ad0b6e1d50cbd9b077c0cecec588544cdf684dffea7f408dfc0cfbdf1a1dbcab28d898711e00f454a748b0c09e4b62b484
|
data/lib/vizzly.rb
CHANGED
|
@@ -27,6 +27,7 @@ module Vizzly
|
|
|
27
27
|
# @param options [Hash] Optional configuration
|
|
28
28
|
# @option options [Hash] :properties Additional properties to attach
|
|
29
29
|
# @option options [Integer] :threshold Pixel difference threshold (0-100)
|
|
30
|
+
# @option options [Integer] :min_cluster_size Minimum cluster size to count as a real difference (default: 2)
|
|
30
31
|
# @option options [Boolean] :full_page Whether this is a full page screenshot
|
|
31
32
|
#
|
|
32
33
|
# @return [Hash, nil] Response data or nil if disabled/failed
|
|
@@ -41,6 +42,7 @@ module Vizzly
|
|
|
41
42
|
# properties: { browser: 'chrome', viewport: { width: 1920, height: 1080 } },
|
|
42
43
|
# threshold: 5
|
|
43
44
|
# )
|
|
45
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
44
46
|
def screenshot(name, image_data, options = {})
|
|
45
47
|
return nil if disabled?
|
|
46
48
|
|
|
@@ -52,20 +54,26 @@ module Vizzly
|
|
|
52
54
|
|
|
53
55
|
image_base64 = Base64.strict_encode64(image_data)
|
|
54
56
|
|
|
57
|
+
# Build properties hash - comparison options merged with user properties
|
|
58
|
+
# Server extracts threshold/minClusterSize from properties, not top-level
|
|
59
|
+
properties = (options[:properties] || {}).merge(
|
|
60
|
+
threshold: options[:threshold],
|
|
61
|
+
minClusterSize: options[:min_cluster_size],
|
|
62
|
+
fullPage: options[:full_page]
|
|
63
|
+
).compact
|
|
64
|
+
|
|
55
65
|
payload = {
|
|
56
66
|
name: name,
|
|
57
67
|
image: image_base64,
|
|
58
68
|
type: 'base64',
|
|
59
69
|
buildId: ENV.fetch('VIZZLY_BUILD_ID', nil),
|
|
60
|
-
|
|
61
|
-
fullPage: options[:full_page] || false,
|
|
62
|
-
properties: options[:properties] || {}
|
|
70
|
+
properties: properties
|
|
63
71
|
}.compact
|
|
64
72
|
|
|
65
73
|
uri = URI("#{@server_url}/screenshot")
|
|
66
74
|
|
|
67
75
|
begin
|
|
68
|
-
response = Net::HTTP.start(uri.host, uri.port, read_timeout: 30) do |http|
|
|
76
|
+
response = Net::HTTP.start(uri.host, uri.port, open_timeout: 10, read_timeout: 30) do |http|
|
|
69
77
|
request = Net::HTTP::Post.new(uri)
|
|
70
78
|
request['Content-Type'] = 'application/json'
|
|
71
79
|
request.body = JSON.generate(payload)
|
|
@@ -125,6 +133,18 @@ module Vizzly
|
|
|
125
133
|
# Disable the SDK after first failure to prevent spam
|
|
126
134
|
disable!('failure')
|
|
127
135
|
|
|
136
|
+
nil
|
|
137
|
+
rescue Net::OpenTimeout
|
|
138
|
+
warn "Vizzly connection timed out for #{name}: couldn't connect within 10s"
|
|
139
|
+
warn "Server URL: #{@server_url}/screenshot"
|
|
140
|
+
warn 'This usually means the server is unreachable (firewall, network issue, or wrong host)'
|
|
141
|
+
disable!('failure')
|
|
142
|
+
nil
|
|
143
|
+
rescue Net::ReadTimeout
|
|
144
|
+
warn "Vizzly request timed out for #{name}: no response within 30s"
|
|
145
|
+
warn "Server URL: #{@server_url}/screenshot"
|
|
146
|
+
warn 'The server may be overloaded or processing is taking too long'
|
|
147
|
+
disable!('failure')
|
|
128
148
|
nil
|
|
129
149
|
rescue StandardError => e
|
|
130
150
|
warn "Vizzly screenshot failed for #{name}: #{e.message}"
|
|
@@ -132,6 +152,7 @@ module Vizzly
|
|
|
132
152
|
nil
|
|
133
153
|
end
|
|
134
154
|
end
|
|
155
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
|
135
156
|
|
|
136
157
|
# Wait for all queued screenshots to be processed
|
|
137
158
|
# (Simple client doesn't need explicit flushing)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vizzly
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vizzly
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-02-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A lightweight client SDK for capturing screenshots and sending them to
|
|
14
14
|
Vizzly for visual regression testing
|