Class: Gitlab::Diff::Rendered::Notebook::DiffFile
- Includes:
- DiffFileHelper, Utils::StrongMemoize
- Defined in:
- lib/gitlab/diff/rendered/notebook/diff_file.rb
Constant Summary collapse
- RENDERED_TIMEOUT_BACKGROUND =
10.seconds
- BACKGROUND_EXECUTION =
'background'
- FOREGROUND_EXECUTION =
'foreground'
- LOG_IPYNBDIFF_GENERATED =
'IPYNB_DIFF_GENERATED'
- LOG_IPYNBDIFF_TIMEOUT =
'IPYNB_DIFF_TIMEOUT'
- LOG_IPYNBDIFF_INVALID =
'IPYNB_DIFF_INVALID'
- LOG_IPYNBDIFF_TRUNCATED =
'IPYNB_DIFF_TRUNCATED'
Constants included from DiffFileHelper
Gitlab::Diff::Rendered::Notebook::DiffFileHelper::EMBEDDED_IMAGE_PATTERN
Constants inherited from File
Instance Attribute Summary collapse
-
#source_diff ⇒ Object
readonly
Returns the value of attribute source_diff.
Attributes inherited from File
#diff_refs, #fallback_diff_refs, #repository, #unique_identifier
Instance Method Summary collapse
- #diff ⇒ Object
- #has_renderable? ⇒ Boolean
- #highlighted_diff_lines ⇒ Object
-
#initialize(diff_file) ⇒ DiffFile
constructor
A new instance of DiffFile.
- #new_blob ⇒ Object
- #old_blob ⇒ Object
- #rendered ⇒ Object
Methods included from DiffFileHelper
#image_as_rich_text, #line_positions_at_source_diff, #lines_in_source_diff, #source_line_from_block, #strip_diff_frontmatter
Methods inherited from File
#add_blobs_to_batch_loader, #added_lines, #alternate_viewer, #binary?, #binary_in_repo?, #blob, #content_changed?, #content_sha, #diff_hunk, #diff_lines, #diff_lines_for_serializer, #diffable?, #different_type?, #empty?, #external_storage, #external_storage_error?, #file_hash, #file_identifier, #file_identifier_hash, #file_path, #fully_expanded?, #highlight_loaded?, #highlighted_diff_lines=, #ipynb?, #line_code, #line_code_for_position, #line_for_line_code, #line_for_position, #new_blob_lines_between, #new_content_sha, #new_sha, #next_line, #old_content_sha, #old_sha, #parallel_diff_lines, #paths, #position, #position_for_line_code, #prev_line, #raw_diff, #raw_size, #removed_lines, #rendered_as_text?, #rich_viewer, #simple_viewer, #size, #stored_externally?, #text?, #text_in_repo?, #unfold_diff_lines, #unfolded?, #viewer
Constructor Details
#initialize(diff_file) ⇒ DiffFile
Returns a new instance of DiffFile.
23 24 25 |
# File 'lib/gitlab/diff/rendered/notebook/diff_file.rb', line 23 def initialize(diff_file) @source_diff = diff_file end |
Instance Attribute Details
#source_diff ⇒ Object (readonly)
Returns the value of attribute source_diff.
18 19 20 |
# File 'lib/gitlab/diff/rendered/notebook/diff_file.rb', line 18 def source_diff @source_diff end |
Instance Method Details
#diff ⇒ Object
39 40 41 |
# File 'lib/gitlab/diff/rendered/notebook/diff_file.rb', line 39 def diff strong_memoize(:diff) { transformed_diff } end |
#has_renderable? ⇒ Boolean
43 44 45 |
# File 'lib/gitlab/diff/rendered/notebook/diff_file.rb', line 43 def has_renderable? !notebook_diff.nil? && diff.diff.present? end |
#highlighted_diff_lines ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/gitlab/diff/rendered/notebook/diff_file.rb', line 51 def highlighted_diff_lines strong_memoize(:highlighted_diff_lines) do lines = Gitlab::Diff::Highlight.new(self, repository: self.repository).highlight lines_in_source = lines_in_source_diff( source_diff.highlighted_diff_lines, source_diff.deleted_file?, source_diff.new_file? ) lines.zip(line_positions_at_source_diff(lines, transformed_blocks)) .map { |line, positions| mutate_line(line, positions, lines_in_source) } end end |
#new_blob ⇒ Object
33 34 35 36 37 |
# File 'lib/gitlab/diff/rendered/notebook/diff_file.rb', line 33 def new_blob return unless notebook_diff strong_memoize(:new_blob) { ::Blobs::Notebook.decorate(source_diff.new_blob, notebook_diff.to.as_text) } end |
#old_blob ⇒ Object
27 28 29 30 31 |
# File 'lib/gitlab/diff/rendered/notebook/diff_file.rb', line 27 def old_blob return unless notebook_diff strong_memoize(:old_blob) { ::Blobs::Notebook.decorate(source_diff.old_blob, notebook_diff.from.as_text) } end |
#rendered ⇒ Object
47 48 49 |
# File 'lib/gitlab/diff/rendered/notebook/diff_file.rb', line 47 def rendered self end |