Class: Dotsync::ContentDiff

Inherits:
Object
  • Object
show all
Defined in:
lib/dotsync/utils/content_diff.rb

Constant Summary collapse

COLORS =
{
  header: 103,       # Purple for file headers
  hunk: 36,          # Cyan for @@ lines
  addition: 34,      # Blue for added lines (consistent with diff_additions)
  deletion: 88,      # Red for removed lines (consistent with diff_removals)
  context: 240       # Gray for context lines
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(src_path, dest_path, logger) ⇒ ContentDiff

Returns a new instance of ContentDiff.



13
14
15
16
17
# File 'lib/dotsync/utils/content_diff.rb', line 13

def initialize(src_path, dest_path, logger)
  @src_path = src_path
  @dest_path = dest_path
  @logger = logger
end

Instance Method Details

#displayObject



19
20
21
22
23
24
25
26
27
# File 'lib/dotsync/utils/content_diff.rb', line 19

def display
  return unless displayable?

  diff_output = generate_diff
  return if diff_output.empty?

  display_header
  colorize_and_display(diff_output)
end