perchfall 0.3.1 → 0.3.2

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: e958ae8eb16aae40c5d8b0b0e91d3798b14306247aac27f09b2ff8dd08b291b8
4
- data.tar.gz: c1f4aca810150d302129aa536ae9df128dad6c6f2b4a12e1873a9078fd999ce0
3
+ metadata.gz: b71c5cd92df55f4c28471df0920f19be7c4b81586d52c76e0704a2d1a605265a
4
+ data.tar.gz: 2dbe1f2b439949f7d7ed2cff08a2a51979e8c02cf1cd7c74c701f3de3a428e01
5
5
  SHA512:
6
- metadata.gz: 83fc8408712d42dc29cf567659b9685c739aa5d5f4483fc8e02afd68624d0f4ea0d1aedbecb0d5bc52e015e119082e9a18cfad91701594988976b1d92de6d63d
7
- data.tar.gz: c56040589ec68c2193df0117be65f6919b243a8c82c475096b813390a27050ea09e645fad54acafe63be85f1a4f343e0c51ac9fa597ba668f28c03a6432090de
6
+ metadata.gz: 2372a6936e06871d890e272e7c722b5dc59e4a2c2ac86e08e882479f3537f85ef3a66bf68b0a913a24029c300740183126437dda332934b975f9bc84fc64146e
7
+ data.tar.gz: fd02d5e014638c12695932361995443ad1f1c6a66aa104c0db360b931e55291cfca1a176aa2353a16267e73c3e651325a94c5ce4bb1f334b3ee4cdadb6ebc6ff
data/CHANGELOG.md CHANGED
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.3.2] - 2026-03-19
11
+
12
+ ### Added
13
+
14
+ - `Perchfall.run!` — like `.run` but raises `PageLoadError` when the report is not ok. Use in scripts or jobs that should abort on any page failure.
15
+
16
+ ### Changed
17
+
18
+ - `Perchfall.run` now always returns a `Report`, even when the page has unignored errors. Callers check `report.ok?` and handle failures themselves. This makes notification workflows possible without rescuing exceptions.
19
+
10
20
  ## [0.3.1] - 2026-03-19
11
21
 
12
22
  ### Changed
@@ -64,7 +74,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
64
74
  - Full dependency injection throughout — test suite runs in ~0.4 s with no browser, Node, or network required
65
75
  - GitHub Actions CI workflow (unit suite) and manual Playwright smoke check workflow
66
76
 
67
- [Unreleased]: https://github.com/beflagrant/perchfall/compare/v0.3.1...HEAD
77
+ [Unreleased]: https://github.com/beflagrant/perchfall/compare/v0.3.2...HEAD
78
+ [0.3.2]: https://github.com/beflagrant/perchfall/compare/v0.3.1...v0.3.2
68
79
  [0.3.1]: https://github.com/beflagrant/perchfall/compare/v0.2.0...v0.3.1
69
80
  [0.2.0]: https://github.com/beflagrant/perchfall/compare/v0.1.0...v0.2.0
70
81
  [0.1.0]: https://github.com/beflagrant/perchfall/releases/tag/v0.1.0
@@ -55,20 +55,36 @@ module Perchfall
55
55
  end
56
56
 
57
57
  # Run a synthetic browser check against the given URL.
58
+ # Always returns a Report — callers must check report.ok? to determine success.
58
59
  #
59
60
  # @param url [String] the URL to check (required, must be http or https)
60
61
  # @param timeout_ms [Integer] ms before Playwright gives up (default 30_000)
61
62
  # @param scenario_name [String, nil] optional label included in the report
62
63
  # @param timestamp [Time] override the run timestamp (default Time.now.utc)
63
- # @return [Report] on success
64
+ # @return [Report]
64
65
  # @raise [ArgumentError] if the URL is not http/https
65
66
  # @raise [Errors::ConcurrencyLimitError] if the concurrency cap is reached
66
67
  # @raise [Errors::InvocationError] if Node could not be started
67
68
  # @raise [Errors::ScriptError] if the Node script exited non-zero
68
69
  # @raise [Errors::ParseError] if the script output was not valid JSON
69
- # @raise [Errors::PageLoadError] if the page itself failed to load
70
+ def run(url:, **opts)
71
+ invoke(url: url, **opts)
72
+ end
73
+
74
+ # Like #run, but raises PageLoadError if the report is not ok.
75
+ # Use this in scripts or jobs that should abort on any page failure.
76
+ #
77
+ # @return [Report] only if report.ok?
78
+ # @raise [Errors::PageLoadError] if the page failed to load or has unignored errors
79
+ def run!(url:, **opts)
80
+ report = invoke(url: url, **opts)
81
+ raise Errors::PageLoadError.new(report) unless report.ok?
82
+ report
83
+ end
84
+
85
+ private
70
86
 
71
- def run(url:, ignore: [], wait_until: "load", timeout_ms: 30_000, scenario_name: nil, timestamp: Time.now.utc, cache_profile: :query_bust)
87
+ def invoke(url:, ignore: [], wait_until: "load", timeout_ms: 30_000, scenario_name: nil, timestamp: Time.now.utc, cache_profile: :query_bust)
72
88
  profile = resolve_cache_profile!(cache_profile)
73
89
  validate_wait_until!(wait_until)
74
90
  validate_timeout_ms!(timeout_ms)
@@ -27,9 +27,7 @@ module Perchfall
27
27
  def run(url:, timestamp:, timeout_ms: 30_000, wait_until: "load", scenario_name: nil, ignore: [], original_url: nil, extra_headers: {}, cache_profile: nil)
28
28
  parser = build_parser(ignore)
29
29
  result = execute(build_command(url: url, timeout_ms: timeout_ms, wait_until: wait_until, extra_headers: extra_headers))
30
- report = parse(result, parser: parser, scenario_name: scenario_name, timestamp: timestamp, original_url: original_url || url, cache_profile: cache_profile)
31
- raise_if_page_load_error(report)
32
- report
30
+ parse(result, parser: parser, scenario_name: scenario_name, timestamp: timestamp, original_url: original_url || url, cache_profile: cache_profile)
33
31
  end
34
32
 
35
33
  private
@@ -62,8 +60,5 @@ module Perchfall
62
60
  parser.parse(result.stdout, **opts)
63
61
  end
64
62
 
65
- def raise_if_page_load_error(report)
66
- raise Errors::PageLoadError.new(report) unless report.ok?
67
- end
68
63
  end
69
64
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Perchfall
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.2"
5
5
  end
data/lib/perchfall.rb CHANGED
@@ -43,9 +43,8 @@ module Perchfall
43
43
  @default_limiter ||= ConcurrencyLimiter.new(limit: 5)
44
44
  end
45
45
 
46
- # Convenience method. Equivalent to Perchfall::Client.new.run(url:, **opts).
47
- # Creates a fresh Client (and thus a fresh PlaywrightInvoker) on each call —
48
- # no shared state between invocations.
46
+ # Returns a Report always — callers check report.ok? to determine success.
47
+ # Use this when you want to handle or notify on failures yourself.
49
48
  #
50
49
  # @param url [String]
51
50
  # @param opts [Hash] forwarded to Client#run
@@ -53,4 +52,15 @@ module Perchfall
53
52
  def self.run(url:, **opts)
54
53
  Client.new.run(url: url, **opts)
55
54
  end
55
+
56
+ # Like .run, but raises PageLoadError if the report is not ok.
57
+ # Use this in scripts or jobs that should abort on any page failure.
58
+ #
59
+ # @param url [String]
60
+ # @param opts [Hash] forwarded to Client#run!
61
+ # @return [Report] only if report.ok?
62
+ # @raise [Errors::PageLoadError]
63
+ def self.run!(url:, **opts)
64
+ Client.new.run!(url: url, **opts)
65
+ end
56
66
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perchfall
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Remsik