Class: Rigor::Analysis::BufferBinding
- Inherits:
-
Data
- Object
- Data
- Rigor::Analysis::BufferBinding
- Defined in:
- lib/rigor/analysis/buffer_binding.rb
Overview
Binds one logical project path (the path the user is editing, e.g. lib/foo.rb) to a physical file
containing the in-flight buffer bytes (e.g. /tmp/9539itfeh2.rb). When the runner / workers / pre-passes
need to read source for the logical path, they read from the physical path instead; when they emit a
Diagnostic, the path is the logical one so editors highlight the buffer the user is actually looking at.
See docs/design/20260516-editor-mode.md for the design. The CLI surfaces this through paired
--tmp-file / --instead-of flags on rigor check and rigor type-of; programmatic callers pass a
BufferBinding to Runner.new.
Instance Attribute Summary collapse
-
#logical_path ⇒ Object
readonly
Returns the value of attribute logical_path.
-
#physical_path ⇒ Object
readonly
Returns the value of attribute physical_path.
Instance Method Summary collapse
-
#display_path(path) ⇒ Object
Returns the path the caller should report in user-facing output (diagnostics, run stats) when it currently holds the physical path.
-
#resolve(path) ⇒ Object
Returns the physical path to read bytes from when the caller is about to parse
path.
Instance Attribute Details
#logical_path ⇒ Object (readonly)
Returns the value of attribute logical_path
13 14 15 |
# File 'lib/rigor/analysis/buffer_binding.rb', line 13 def logical_path @logical_path end |
#physical_path ⇒ Object (readonly)
Returns the value of attribute physical_path
13 14 15 |
# File 'lib/rigor/analysis/buffer_binding.rb', line 13 def physical_path @physical_path end |
Instance Method Details
#display_path(path) ⇒ Object
Returns the path the caller should report in user-facing output (diagnostics, run stats) when it
currently holds the physical path. The inverse of #resolve. Non-physical paths pass through
unchanged, so it is safe to stamp every outgoing path through this helper.
24 25 26 |
# File 'lib/rigor/analysis/buffer_binding.rb', line 24 def display_path(path) path == physical_path ? logical_path : path end |
#resolve(path) ⇒ Object
Returns the physical path to read bytes from when the caller is about to parse path. For non-logical
paths returns the input unchanged. Cheap to call on every path; the binding is singular today (one
buffer per run).
17 18 19 |
# File 'lib/rigor/analysis/buffer_binding.rb', line 17 def resolve(path) path == logical_path ? physical_path : path end |