Class: RosettAi::Provenance::TrailerGenerator
- Inherits:
-
Object
- Object
- RosettAi::Provenance::TrailerGenerator
- 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
-
#generate(entry) ⇒ String
Generates a commit trailer from a provenance entry.
-
#generate_all(data) ⇒ Array<String>
Generates trailers for all entries in a provenance dataset.
-
#trailer_block(data) ⇒ String
Formats trailers as a block suitable for appending to a commit message.
Instance Method Details
#generate(entry) ⇒ String
Generates a commit trailer from a provenance entry.
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.
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.
38 39 40 |
# File 'lib/rosett_ai/provenance/trailer_generator.rb', line 38 def trailer_block(data) generate_all(data).join("\n") end |