Class: Textus::Infra::Port::Sentinel
- Inherits:
-
Object
- Object
- Textus::Infra::Port::Sentinel
- Defined in:
- lib/textus/infra/port/sentinel.rb
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.
7 8 9 10 11 12 |
# File 'lib/textus/infra/port/sentinel.rb', line 7 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.
5 6 7 |
# File 'lib/textus/infra/port/sentinel.rb', line 5 def mode @mode end |
#sha256 ⇒ Object (readonly)
Returns the value of attribute sha256.
5 6 7 |
# File 'lib/textus/infra/port/sentinel.rb', line 5 def sha256 @sha256 end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
5 6 7 |
# File 'lib/textus/infra/port/sentinel.rb', line 5 def source @source end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
5 6 7 |
# File 'lib/textus/infra/port/sentinel.rb', line 5 def target @target end |
Instance Method Details
#drift?(file_stat) ⇒ Boolean
16 17 18 19 20 21 |
# File 'lib/textus/infra/port/sentinel.rb', line 16 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
14 |
# File 'lib/textus/infra/port/sentinel.rb', line 14 def orphan?(file_stat) = @target.nil? || !file_stat.exists?(@target) |