vizzly 0.1.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 +26 -4
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83c5bb29a091449d684562effec3161f0ddab82fe2be22b3d357cb66723d44b9
4
- data.tar.gz: 1a97c02f6b0d670a6841d9536ee7fe434340b5ca210bf315f764a03e350e360c
3
+ metadata.gz: 0d871ec31907ae78a9790e8763340300d5b3b0860048ad3bde1d540e8de746e2
4
+ data.tar.gz: e03b0e7d53d526c82d813a3a9435cb3bb77a7af9450c2de5ddc03f09f7c05815
5
5
  SHA512:
6
- metadata.gz: 64a47f4a33270a9a82c4c1edbe267e4ef2eedd7f0f096859f28a306aa53d90401ffb3440cc5f7191a2138e2a6ac732dc1214b4d029c911e3d7d705f30a692056
7
- data.tar.gz: f16bd4924bcfc9a2ddadbe0d639f01267853a1d2107dab97eb65e2d7ff1f01d63a21bd8db82a76cb4d1c281bacde9bc3fae38d194733dfb26f1f465a98ff68b3
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,19 +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,
68
+ type: 'base64',
58
69
  buildId: ENV.fetch('VIZZLY_BUILD_ID', nil),
59
- threshold: options[:threshold] || 0,
60
- fullPage: options[:full_page] || false,
61
- properties: options[:properties] || {}
70
+ properties: properties
62
71
  }.compact
63
72
 
64
73
  uri = URI("#{@server_url}/screenshot")
65
74
 
66
75
  begin
67
- 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|
68
77
  request = Net::HTTP::Post.new(uri)
69
78
  request['Content-Type'] = 'application/json'
70
79
  request.body = JSON.generate(payload)
@@ -124,6 +133,18 @@ module Vizzly
124
133
  # Disable the SDK after first failure to prevent spam
125
134
  disable!('failure')
126
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')
127
148
  nil
128
149
  rescue StandardError => e
129
150
  warn "Vizzly screenshot failed for #{name}: #{e.message}"
@@ -131,6 +152,7 @@ module Vizzly
131
152
  nil
132
153
  end
133
154
  end
155
+ # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
134
156
 
135
157
  # Wait for all queued screenshots to be processed
136
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.1.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: 2025-10-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