close_encounters 0.2.3 → 0.2.4
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 +2 -10
- data/README.md +4 -0
- data/Rakefile +1 -0
- data/lib/close_encounters/version.rb +1 -1
- data/lib/close_encounters.rb +42 -14
- 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: be9653e9826ea4a3ba675cc0a35c68eb9ff77404e8ae5569a2834682b4800a61
|
|
4
|
+
data.tar.gz: 8d61d965ce13c0e67a960bc90a4ace544ad215aa6d58f7c28c04a140258f6ab9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8f279069dfbdaa9aff1e4802d15950dbc03f6ad411bcb174f4935efb4a2bbe245cf920c6cd00a522365c8a45c56202ae5a06568a67ba6fdc4965ed101586bdba
|
|
7
|
+
data.tar.gz: 207655591aedb84b5cbf5b0e5a5c78e4d7239f3dd00d57978a46c227b3aca59cb52c89c99137adb46e0d7e50412785063b86579edc252b6428ded9c81e21333e
|
data/CHANGELOG.md
CHANGED
|
@@ -5,18 +5,10 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
7
7
|
|
|
8
|
+
## [0.2.4] - 2026-04-06
|
|
9
|
+
|
|
8
10
|
## [0.2.3] - 2025-09-08
|
|
9
11
|
|
|
10
12
|
### Fixed
|
|
11
13
|
|
|
12
14
|
- Fix duplicate event creation in `scan` method when status and verification state are unchanged
|
|
13
|
-
|
|
14
|
-
## [0.2.2] - 2025-09-04
|
|
15
|
-
|
|
16
|
-
### Changed
|
|
17
|
-
|
|
18
|
-
- Update handling of the same status for multiple requests when creating events.
|
|
19
|
-
|
|
20
|
-
### Fixed
|
|
21
|
-
|
|
22
|
-
- Ensure that status is an integer when creating events and comparing results.
|
data/README.md
CHANGED
|
@@ -67,5 +67,9 @@ Or install it yourself as:
|
|
|
67
67
|
$ gem install close_encounters
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
+
## Releasing
|
|
71
|
+
|
|
72
|
+
This project is managed with [Reissue](https://github.com/SOFware/reissue). Releases are automated via the [shared release workflow](https://github.com/SOFware/reissue/blob/main/.github/workflows/SHARED_WORKFLOW_README.md). Trigger a release by running the "Release gem to RubyGems.org" workflow from the Actions tab.
|
|
73
|
+
|
|
70
74
|
## License
|
|
71
75
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
data/lib/close_encounters.rb
CHANGED
|
@@ -41,17 +41,30 @@ module CloseEncounters
|
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
+
VERIFIED_SIGNATURE = "ok"
|
|
45
|
+
UNVERIFIED_SIGNATURE = "unverified"
|
|
46
|
+
|
|
44
47
|
# Record a verification of a contact with a third party service where the
|
|
45
48
|
# verification is a callable which must also respond to to_s.
|
|
46
49
|
#
|
|
50
|
+
# The verifier may return:
|
|
51
|
+
# * true / :ok — response is verified
|
|
52
|
+
# * false / nil — response failed verification (generic)
|
|
53
|
+
# * any other value — failed verification with a distinguishing
|
|
54
|
+
# "signature" (e.g. "missing:user.email").
|
|
55
|
+
# Stable signatures let scan suppress repeated
|
|
56
|
+
# identical failures while still recording when
|
|
57
|
+
# the failure mode changes meaningfully.
|
|
58
|
+
#
|
|
47
59
|
# Creates a new event if:
|
|
48
|
-
# 1. The status has changed from the last recorded status
|
|
49
|
-
# 2.
|
|
60
|
+
# 1. The status has changed from the last recorded status, OR
|
|
61
|
+
# 2. The status is in the verify_scan list AND the verification signature
|
|
62
|
+
# differs from the last recorded signature.
|
|
50
63
|
#
|
|
51
64
|
# @param name [String] the name of the service
|
|
52
65
|
# @param status [Integer] the HTTP status of the contact
|
|
53
66
|
# @param response [String] the response object
|
|
54
|
-
# @param verifier [
|
|
67
|
+
# @param verifier [#call, #to_s] the verification callable
|
|
55
68
|
def scan(name, status:, response:, verifier:)
|
|
56
69
|
service = ParticipantService.find_by!(name:)
|
|
57
70
|
status = status.to_i # Ensure status is always an integer
|
|
@@ -59,23 +72,38 @@ module CloseEncounters
|
|
|
59
72
|
service.with_lock do
|
|
60
73
|
last_event = service.events.newest.first
|
|
61
74
|
last_status = last_event&.status
|
|
62
|
-
last_verified = last_event&.verified?
|
|
63
75
|
|
|
64
|
-
|
|
65
|
-
verified =
|
|
76
|
+
signature = signature_for(verifier.call(response))
|
|
77
|
+
verified = (signature == VERIFIED_SIGNATURE)
|
|
78
|
+
last_signature = signature_for_event(last_event)
|
|
79
|
+
|
|
80
|
+
metadata = {verified:, signature:, verification: verifier.to_s}
|
|
66
81
|
|
|
67
|
-
# Create a new event if:
|
|
68
|
-
# 1. Status has changed OR
|
|
69
|
-
# 2. Status is in verify_scan_statuses AND verified flag has changed
|
|
70
82
|
if last_status != status
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
# Status same but verification result changed for a monitored status
|
|
75
|
-
service.events.create!(status:, response:, metadata: {verified:, verification: verifier.to_s})
|
|
83
|
+
service.events.create!(status:, response:, metadata:)
|
|
84
|
+
elsif verify_scan_statuses.include?(status) && last_signature != signature
|
|
85
|
+
service.events.create!(status:, response:, metadata:)
|
|
76
86
|
end
|
|
77
87
|
end
|
|
78
88
|
end
|
|
89
|
+
|
|
90
|
+
# Normalize a verifier return value into a stable signature string.
|
|
91
|
+
def signature_for(result)
|
|
92
|
+
case result
|
|
93
|
+
when true, :ok then VERIFIED_SIGNATURE
|
|
94
|
+
when false, nil then UNVERIFIED_SIGNATURE
|
|
95
|
+
else result.to_s
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Read the signature off a previously stored event, falling back to the
|
|
100
|
+
# legacy verified flag for events created before signatures existed.
|
|
101
|
+
def signature_for_event(event)
|
|
102
|
+
return nil unless event
|
|
103
|
+
stored = event.metadata.to_h["signature"]
|
|
104
|
+
return stored if stored
|
|
105
|
+
event.verified? ? VERIFIED_SIGNATURE : UNVERIFIED_SIGNATURE
|
|
106
|
+
end
|
|
79
107
|
alias_method :verify, :scan
|
|
80
108
|
module_function :verify
|
|
81
109
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: close_encounters
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jim Gay
|
|
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
142
142
|
- !ruby/object:Gem::Version
|
|
143
143
|
version: '0'
|
|
144
144
|
requirements: []
|
|
145
|
-
rubygems_version: 3.
|
|
145
|
+
rubygems_version: 3.7.2
|
|
146
146
|
specification_version: 4
|
|
147
147
|
summary: Close Encounters of the Third Party
|
|
148
148
|
test_files: []
|