Class: RubyCode::Views::WriteApproval
- Inherits:
-
Object
- Object
- RubyCode::Views::WriteApproval
- Defined in:
- lib/rubycode/views/write_approval.rb
Overview
Builds file write approval prompt display
Class Method Summary collapse
- .build(file_path:, content:) ⇒ Object
- .file_info_section(pastel, file_path, content) ⇒ Object
- .header_section(pastel) ⇒ Object
- .preview_section(content) ⇒ Object
- .truncation_notice(pastel, content) ⇒ Object
Class Method Details
.build(file_path:, content:) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rubycode/views/write_approval.rb', line 9 def self.build(file_path:, content:) pastel = Pastel.new [ "", header_section(pastel), file_info_section(pastel, file_path, content), pastel.yellow("─" * 80), preview_section(content), truncation_notice(pastel, content), pastel.yellow("━" * 80) ].compact.join("\n") end |
.file_info_section(pastel, file_path, content) ⇒ Object
27 28 29 |
# File 'lib/rubycode/views/write_approval.rb', line 27 def self.file_info_section(pastel, file_path, content) ["#{pastel.cyan("File:")} #{file_path}", "#{pastel.cyan("Lines:")} #{content.lines.count}"].join("\n") end |
.header_section(pastel) ⇒ Object
23 24 25 |
# File 'lib/rubycode/views/write_approval.rb', line 23 def self.header_section(pastel) [pastel.yellow("━" * 80), pastel.bold("Write Operation - Approval Required")].join("\n") end |
.preview_section(content) ⇒ Object
31 32 33 |
# File 'lib/rubycode/views/write_approval.rb', line 31 def self.preview_section(content) content.lines.first(20).join end |
.truncation_notice(pastel, content) ⇒ Object
35 36 37 38 39 |
# File 'lib/rubycode/views/write_approval.rb', line 35 def self.truncation_notice(pastel, content) return "" unless content.lines.count > 20 pastel.dim("... (#{content.lines.count - 20} more lines)") end |