Class: RSpecTracer::Tracker::Input Private
- Inherits:
-
Struct
- Object
- Struct
- RSpecTracer::Tracker::Input
- Defined in:
- lib/rspec_tracer/tracker/input.rb,
lib/rspec_tracer/tracker/input.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Internal Input — see RSpecTracer for the user-facing surface.
Instance Attribute Summary collapse
-
#digest ⇒ Object
Returns the value of attribute digest.
-
#identity ⇒ Object
Returns the value of attribute identity.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
-
.for_file(path:, kind:, digest:, root:) ⇒ Object
private
Internal helper for the tracer pipeline.
-
.relative_path(abs_path, root) ⇒ Object
private
Strip ‘root/` prefix from an absolute path.
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
private
Inputs are value-typed and not meant to be subclassed; ‘instance_of?` is precise where `is_a?` would let a subclass with matching identity compare equal.
-
#hash ⇒ Object
private
Internal method on the tracer pipeline.
-
#stale?(current_digest) ⇒ Boolean
private
‘!=` handles every case correctly: nil-vs-nil is NOT stale (absent stayed absent), present-vs-nil and nil-vs-present are stale (file appeared/disappeared), and digest-vs-digest is stale iff the content changed.
Instance Attribute Details
#digest ⇒ Object
Returns the value of attribute digest
41 42 43 |
# File 'lib/rspec_tracer/tracker/input.rb', line 41 def digest @digest end |
#identity ⇒ Object
Returns the value of attribute identity
41 42 43 |
# File 'lib/rspec_tracer/tracker/input.rb', line 41 def identity @identity end |
#kind ⇒ Object
Returns the value of attribute kind
41 42 43 |
# File 'lib/rspec_tracer/tracker/input.rb', line 41 def kind @kind end |
#path ⇒ Object
Returns the value of attribute path
41 42 43 |
# File 'lib/rspec_tracer/tracker/input.rb', line 41 def path @path end |
Class Method Details
.for_file(path:, kind:, digest:, root:) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Internal helper for the tracer pipeline.
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rspec_tracer/tracker/input.rb', line 48 def self.for_file(path:, kind:, digest:, root:) unless ALLOWED_INPUT_KINDS.include?(kind) raise ArgumentError, "invalid Input kind: #{kind.inspect}; " \ "allowed: #{ALLOWED_INPUT_KINDS.to_a.inspect}" end abs_path = File.(path) identity = "#{kind}:#{relative_path(abs_path, root)}" new(path: abs_path, kind: kind, digest: digest, identity: identity).freeze end |
.relative_path(abs_path, root) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Strip ‘root/` prefix from an absolute path. When the path escapes the root (absolute symlink target, vendored gem under a different tree, etc.) we fall back to the full absolute path so identity stays unique - the deterministic rule is “same path under same root => same identity”, nothing stronger.
66 67 68 69 70 71 72 73 |
# File 'lib/rspec_tracer/tracker/input.rb', line 66 def self.relative_path(abs_path, root) root_abs = File.(root) prefix = "#{root_abs}/" return abs_path unless abs_path.start_with?(prefix) abs_path[prefix.length..] end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Inputs are value-typed and not meant to be subclassed; ‘instance_of?` is precise where `is_a?` would let a subclass with matching identity compare equal.
86 87 88 |
# File 'lib/rspec_tracer/tracker/input.rb', line 86 def ==(other) other.instance_of?(self.class) && identity == other.identity end |
#hash ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Internal method on the tracer pipeline.
94 95 96 |
# File 'lib/rspec_tracer/tracker/input.rb', line 94 def hash identity.hash end |
#stale?(current_digest) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
‘!=` handles every case correctly: nil-vs-nil is NOT stale (absent stayed absent), present-vs-nil and nil-vs-present are stale (file appeared/disappeared), and digest-vs-digest is stale iff the content changed.
79 80 81 |
# File 'lib/rspec_tracer/tracker/input.rb', line 79 def stale?(current_digest) current_digest != digest end |