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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vizzly.rb +25 -4
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0011bf796b1114bd00011a649d41cb860d4658cc4d98164f53d4e2308404d6c2
4
- data.tar.gz: 14551857950efde73e174cb04d46be7192724262978f4a009f99bde06da9daea
3
+ metadata.gz: 0d871ec31907ae78a9790e8763340300d5b3b0860048ad3bde1d540e8de746e2
4
+ data.tar.gz: e03b0e7d53d526c82d813a3a9435cb3bb77a7af9450c2de5ddc03f09f7c05815
5
5
  SHA512:
6
- metadata.gz: c66401d88b74442243b1f01c44a479d58844c0448c3b954bedcd823ea777a96408d87ce98e6b02b8a3812751a4381ff0073a448d469c2156a45169a17154d104
7
- data.tar.gz: 3c30f1d6e5cd13ce62a2a779fce10410f8b0f525e29fa92ecfe10cf520c7ac4db33ff9defb241967ee21c0fff94a8293cae6aee009b274ba5dadfc1437baaa90
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
- threshold: options[:threshold] || 0,
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.0
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-01-07 00:00:00.000000000 Z
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