Copyright (c) 2006, Chris Parsons (chris@edendevelopment.co.uk) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Chris Parsons nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ----------- INVOICE DSL ----------- *Summary* This invoice DSL allows you to write invoices using a simple Ruby-like syntax and then process them using various filters to get the output that you need. I wrote it for fun, to learn about DSLs in Ruby, and also for a quick way to do my invoice calculations. *Development* The code is GPL'd, so feel free to modify it, but I'd appreciate a patch so that I can merge any bugfixes or enhancements back into the trunk and benefit everyone. If you wish to submit a patch, please install rspec and make sure that 'spec invoice_spec.rb' passes before you submit. Send patches to info@edendevelopment.co.uk. *Installation* $ svn co http://svn.edendevelopment.co.uk/public/invoice_dsl This will install the code into your current directory. Simple, huh? :-) *Quick Start* 1. First write your invoice and save it as 'myinvoice.rb'. You can use 'example_invoices.rb' for reference. 2. Run the following command: ./process_invoice.rb myinvoice.rb invoice_template.tex This will save out a number of invoices into 'tex' files, with filenames corresponding to the 'codes' you have given the invoice in step 1. For example, the example_invoices.rb file generates the following files when run as above: 2006-45.tex 2006-46.tex As an added bonus, the process_invoice script will invoke 'pdflatex' for you to generate pdfs for each of these files, if you have it. Check out 2006-45.pdf for the final example output. *Writing new templates* The LaTeX template is the main one, but I've included a quick YAML template also - this simply produces a YAML file for each invoice, which can then be processed futher. The template use ERB for expansion, so pretty much any ERB template will do the trick. Use the 'invoice_template.tex' as an example. It should be trivial to add invoice templates for HTML, plus other formats; if you produce any let me know! *Tip* Create a pdf and save it as 'background.pdf' in the same directory as the script, and the LaTeX template will use it as the background of the PDF it generates. I use this for my letterhead on invoices I don't intend to print but send electronically.