Class: RosettAi::Provenance::FileSource

Inherits:
Object
  • Object
show all
Defined in:
lib/rosett_ai/provenance/file_source.rb

Overview

Represents a file-level source reference within a provenance entry.

Tracks which files were involved in an AI contribution and what lines or sections were affected.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, source_type:, lines: nil) ⇒ FileSource

Returns a new instance of FileSource.

Parameters:

  • path (String)

    relative path from project root

  • lines (String, nil) (defaults to: nil)

    line range (e.g. "1-50") or nil for whole file

  • source_type (String)

    one of Source::ALLOWED_TYPES



18
19
20
21
22
# File 'lib/rosett_ai/provenance/file_source.rb', line 18

def initialize(path:, source_type:, lines: nil)
  @path = path.freeze
  @lines = lines&.freeze
  @source_type = source_type.freeze
end

Instance Attribute Details

#linesObject (readonly)

Returns the value of attribute lines.



13
14
15
# File 'lib/rosett_ai/provenance/file_source.rb', line 13

def lines
  @lines
end

#pathObject (readonly)

Returns the value of attribute path.



13
14
15
# File 'lib/rosett_ai/provenance/file_source.rb', line 13

def path
  @path
end

#source_typeObject (readonly)

Returns the value of attribute source_type.



13
14
15
# File 'lib/rosett_ai/provenance/file_source.rb', line 13

def source_type
  @source_type
end

Instance Method Details

#to_hHash

Returns serializable representation.

Returns:

  • (Hash)

    serializable representation



25
26
27
28
29
# File 'lib/rosett_ai/provenance/file_source.rb', line 25

def to_h
  hash = { 'path' => @path, 'source_type' => @source_type }
  hash['lines'] = @lines if @lines
  hash
end