$ show strzibny/invoice_printer
InvoicePrinter is a Ruby library for generating PDF invoices, with additional CLI and HTTP server interfaces. It takes structured invoice data (as Ruby objects or JSON) and generates formatted PDF documents using the Prawn library. The system consists of three main components: the core library for PDF generation, a command-line executable for direct use, and a server executable providing a HTTP API. The architecture shows good separation of concerns with distinct modules for data models, PDF rendering, font handling, and server interface.
The LLM identified 4 files worth highlighting for reuse:
Manages built-in and custom font loading for Prawn PDF generation. Provides a clean abstraction for registering font families with Prawn and handling the fallback to built-in fonts (Overpass, OpenSans, Roboto) when file paths aren't available. Demonstrates skill in encapsulating font handling logic that could be reused in any Prawn-based project.
Defines the InvoicePrinter::Document class representing invoice data with proper type coercion and JSON serialization/deserialization. Includes validation to ensure items are of correct type. Shows good practice in separating data representation from presentation logic, making it reusable in any invoicing context.
Defines the InvoicePrinter::Document::Item class for individual line items in an invoice. Includes JSON serialization/deserialization and proper string conversion of attributes. Represents a clean, reusable data model for invoice line items that could be extracted for use in other invoicing or billing systems.
Provides a thin HTTP API layer over the core invoice printing library using Roda. Handles JSON request/response parsing, parameter validation, error handling, and maps HTTP endpoints to library methods. Demonstrates a reusable pattern for exposing Ruby libraries as HTTP services with consistent error handling and clean separation of concerns.