Invoice DSL: blog moved to pa.rsons.org

Posted by Chris Fri, 17 Nov 2006 11:36:00 GMT

For those of you following the invoice DSL project, please head over to pa.rsons.org and sign on up. I’ll post future articles there as they fit better on that blog.

In the future, I plan to keep this blog focused on Pin in the Map updates, and the other services we run.

Thanks

Chris

Posted in company, ruby

Invoice DSL: Now with time and currencies!

Posted by Chris Thu, 05 Oct 2006 09:56:00 GMT

Thanks for the useful comments on the DSL.

Inspired by what I’ve achieved so far, I’ve pushed ahead and added currency support and time stuff to it. You don’t have to use the currency stuff if you don’t want to… all previous operations still work.

Currency support is pretty dynamic – check out the currency_spec.rb for a full spec, but the long and short of it is that you can do this:

1.pound.is_worth 1.88.dollars

Or, if you fancy it:

1.pound | 1.88.dollars

You can even make up your own currencies if it takes your fancy….

1.sofa.is_worth 20.pounds
20.sofas.in.pounds # prints '400'

This then extends to invoices in the following way:

i = new_invoice do
  1.pound | 1.5.euros

  work_at 20.pounds / hour do
    spent 2.hours.on('Some work')
    spent 2.days.on('More work') # Note: assumes a day is 8 hours long
  end
end

print i.total.in.pounds # prints '360.00'
print i.total.in.euros # prints '540.00'

Neat, huh?

Get the code here. Let me know what you think.

Posted in ruby

Domain Specific Language for Invoices

Posted by Chris Tue, 03 Oct 2006 10:37:00 GMT

5th Oct 06: Updated: now with time and currency support

I’ve been playing around with DSLs recently, inspired by the dynamism you get for free with Ruby, and thought I’d try writing one.

This is my first effort: svn.edendevelopment.co.uk/public/invoice_dsl

Check out the README.txt for more details. Basically it allows you to write an invoice in fairly natural language syntax…

Read more...

Posted in ruby

This is the obligatory blog of Eden Development. We write here about Pin in the Map updates and other stuff we get up to.

Search

Advertisements

Powered