Class: Textus::Domain::Sentinel
- Inherits:
-
Object
- Object
- Textus::Domain::Sentinel
- Defined in:
- lib/textus/domain/sentinel.rb
Overview
Pure value object representing a published-file sentinel. Holds the recorded target path, source path, sha256 checksum, and publish mode. Has no filesystem I/O — path layout and persistence live in Ports::SentinelStore; predicate methods accept a FileStat port for existence and content checks.
Instance Attribute Summary collapse
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#sha256 ⇒ Object
readonly
Returns the value of attribute sha256.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #drift?(file_stat) ⇒ Boolean
-
#initialize(target:, source:, sha256:, mode:) ⇒ Sentinel
constructor
A new instance of Sentinel.
- #orphan?(file_stat) ⇒ Boolean
Constructor Details
#initialize(target:, source:, sha256:, mode:) ⇒ Sentinel
Returns a new instance of Sentinel.
13 14 15 16 17 18 |
# File 'lib/textus/domain/sentinel.rb', line 13 def initialize(target:, source:, sha256:, mode:) @target = target @source = source @sha256 = sha256 @mode = mode end |
Instance Attribute Details
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
11 12 13 |
# File 'lib/textus/domain/sentinel.rb', line 11 def mode @mode end |
#sha256 ⇒ Object (readonly)
Returns the value of attribute sha256.
11 12 13 |
# File 'lib/textus/domain/sentinel.rb', line 11 def sha256 @sha256 end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
11 12 13 |
# File 'lib/textus/domain/sentinel.rb', line 11 def source @source end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
11 12 13 |
# File 'lib/textus/domain/sentinel.rb', line 11 def target @target end |
Instance Method Details
#drift?(file_stat) ⇒ Boolean
22 23 24 25 26 27 |
# File 'lib/textus/domain/sentinel.rb', line 22 def drift?(file_stat) return false if orphan?(file_stat) return false if @sha256.nil? Digest::SHA256.hexdigest(file_stat.read(@target)) != @sha256 end |
#orphan?(file_stat) ⇒ Boolean
20 |
# File 'lib/textus/domain/sentinel.rb', line 20 def orphan?(file_stat) = @target.nil? || !file_stat.exists?(@target) |