Class: RosettAi::Provenance::TrailerGenerator

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

Overview

Generates commit trailers from provenance entries.

Produces standardised commit trailers in the format: Role: Tool Version (Provider)

Instance Method Summary collapse

Instance Method Details

#generate(entry) ⇒ String

Generates a commit trailer from a provenance entry.

Parameters:

  • entry (Entry, Hash)

    provenance entry

Returns:

  • (String)

    formatted commit trailer



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

def generate(entry)
  entry_hash = entry.is_a?(Hash) ? entry : entry.to_h
  role = entry_hash['ai_role'] || entry_hash[:ai_role]
  tool = entry_hash['ai_tool'] || entry_hash[:ai_tool]

  "#{role}: #{tool}"
end

#generate_all(data) ⇒ Array<String>

Generates trailers for all entries in a provenance dataset.

Parameters:

  • data (Hash)

    full provenance data with 'entries' key

Returns:

  • (Array<String>)

    unique trailers



29
30
31
32
# File 'lib/rosett_ai/provenance/trailer_generator.rb', line 29

def generate_all(data)
  entries = data.fetch('entries', [])
  entries.map { |entry| generate(entry) }.uniq
end

#trailer_block(data) ⇒ String

Formats trailers as a block suitable for appending to a commit message.

Parameters:

  • data (Hash)

    full provenance data

Returns:

  • (String)

    newline-separated trailer block



38
39
40
# File 'lib/rosett_ai/provenance/trailer_generator.rb', line 38

def trailer_block(data)
  generate_all(data).join("\n")
end