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