Moneytrackin is a cool online accounting application that lets you track expenses and income, unlike other accounting applications it lets you add tags to each transactions. I love it!  Tagging transactions makes it easier to track exactly where my money is going; not only can I see how much money I’ve spent on junk food but also at which store, and all without having to explicitly create an account for that store.

Unfortunately Moneytracking has an annoying limitation which prevents you from tracking tags across accounts, so if you’re buying junk food with cash and credit tagging loses it appeal.  Luckily, they provide an API which will allow us to easily get around the tagging limitation programmatically. 

I can imagine some pretty cool analytics and infographics coming out of 6 months of data so I wrote Moneytrackin.rb, a Ruby interface to the MoneyTrackin API.  It exposes easy-to-use methods to interact with your Moneytrackin account. While it only implements the methods exposed by their API but I intend to add more functionality like tag searches across all accounts soon, imagine piping an amounte-weighted stream of tags to wordle!

With two gems, HTTParty and Mash, I was easily able to create the client interface.  I included the HTTParty module within connection class and it gave it a "get" method that retrieves data over HTTP.   Usage is simple:

response = self.class.get(self.class.base_uri + '/listProjects/')

Then I passed the response to Mash which converts the XML response into a hash that acts more like a an object., it also also recursively descends down the response converting hashes into Mashes making it easy to get the transactions and the tags associated with them.

SQLite is a great little embeddable database engine but the installation of the Ruby library is not obvious or straightforward on Windows XP or Vista.  To install SQLite for Ruby 1.8, perform the following steps:

  1. download sqlitedll-3_6_18.zip,
  2. copy the two files that are part of the archive to your Ruby bin directory;
  3. run “gem install –version 1.2.3 sqlite3-ruby” from the command prompt.

Enjoy!

Coming from a .NET background and having applied SOLID principles to software development, I was surprised by the lack of inversion of control containers for Python.

The few discussions I read online implied that Python doesn’t need an IoC framework because it is a dynamically typed language.  Dynamically typed languages eliminate the need to use interfaces, they do not do away with the need for inversion of control.

IoC is used to decouple components of an application, remove direct dependencies so that replacing a component will not have a side effects on the rest of the system.  As Dave Thomas explains

a DI application is written as a set of loosely coupled components. These components contain no knitting code: nothing in the application code itself is responsible, for example, for making sure that the necessary objects somehow get an instance of the database connection. Instead, the components all run in a container. This container is given a description of the knitting to be done (typically using an XML file). The container then instantiates objects and sets them into components that need them

I’m new to the language and there maybe a more “pythonic” way to handle inversion of control than using a container. Here is small and contrived example of inversion of control using Pinsor, a IoC container in Python. Those coming from a .NET or Java background will find Pinsor easy to use, but slightly lacking in features.

Search