Nyan Cat RSpec Formatter

Written by Matt on / Nov 16

I watch a lot of tests run in a given day. So I figured why not make it more fun. Inspired by minitest's pride, and um cats? I came up with a Nyan Cat inspired RSpec formatter.

Update: After last week's launch, Nyan Cat received a great response from the Ruby world. Over the weekend, I released version 0.0.2. It includes a few bug fixes and some really cool enhancements. Most notably, Nyan Cat now spans multiple lines. In addition, it displays running totals of passing, pending, and failed specs. Thanks to everyone who contributed! Checkout the new screencast below.

_-_-_-_-_-_-_-|   /\_/\
-_-_-_-_-_-_-~|__( ^ .^)
_-_-_-_-_-_-_-""  ""

Nyan Cat

Much like Nyan, Nyan Cat simply creates a rainbow trail of test results. It counts the number of examples as they execute and highlights failed and pending specs. The rainbow changes colors as it runs and if all the specs pass, Nyan Cat falls asleep. If there are any pending or failing specs, Nyan cat is concerned and can't sleep.

Here's a short demo of Nyan Cat in action.

Installing Nyan Cat is easy. Just install the gem nyan-cat-formatter and simply put the options in your .rspec file:

--format NyanCatFormatter

Checkout the code on Github and let me know how you like it. If you run into any issues, please create an issue on Github and I will be sure to get it fixed. Of course you can always fork the project and send me a pull request.

Have fun!

Gaga, A Git-Backed Key/Value Store

Written by Matt on / Oct 12

Gaga originated from my winning entry in Codebrawl's Key/Value Store contest. The challenge was to write the best key/value storage backend you can think of. Since Git is fast, reliable, and a great tool for storing source code, I was really interested in making an easy way to store key/values.

Built with Grit, Gaga supports SET, GET, KEYS, and DELETE operations. And since it's Git, we can easily enhance it to include other awesome Git features such as branches, diffs, reverting, etc.


@gaga = Gaga.new(:repo => '/path/to/repo')

@gaga['lady'] = "gaga"

@gaga['lady'] #=> "gaga"

@gaga.keys  #=> ['lady']

@gaga.delete('lady') #=> 'gaga'

# Remove all items from the store

That works pretty well. Now, we can harness the power of Git and enhance our data store. For example, we can get a history log for a specific key:


# Produces:
 {"message"=>"all clear","committer"=>{"name"=>"Matt Sears", "email"=>"matt@mattsears.com"}, "committed_date"=>"2011-09-05..."},
 {"message"=>"set 'lady' ", "committer"=>{"name"=>"Matt Sears", "email"=>"matt@mattsears.com"}, "committed_date"=>"2011-09-05..."}
 {"message"=>"delete 'lady' ", "committer"=>{"name"=>"Matt Sears", "email"=>"matt@mattsears.com"}, "committed_date"=>"2011-09-05..."}

This is just a start. There's still a lot things we can add. If you are interested in more detailed information, check out the repo on Github.

Print Stamps With Ruby!

Written by Matt on / May 15

I've just released Stamps - A Ruby gem for creating postage labels, calculate the shipping cost of packages, standardize domestic addresses via USPS CASS certified Address Matching Software, and track shipments using the Stamps.com Web Services API.

Quick Start

First, you will need to register for a (free) developer account at Stamps.com. Once you receive your test credentials and integration id, just plug them into the configuration block:

Stamps.configure do |config|
  config.username       = 'STAMPS USERNAME'
  config.password       = 'STAMPS PASSWORD'

For a simple test, we can call Stamps.account to retreive information about the account. By default, Stamps will return all responses as a Hash.

Create a Stamp

First, we need to standardize the shipping address that complies with the USPS address formatting guidelines:

standardized_address = Stamps.clean_address(
  :address => {
    :full_name => 'The White House',
    :address1  => '1600 Pennsylvania Avenue, NW',
    :city      => 'Washington',
    :state     => 'DC',
    :zip_code  => '20500'

Now that we have a clean address we can create a new stamp. The Stamps.create! takes the sender and receiver address along with parameters on the rate:

stamp = Stamps.create!(
    :rate          => {
      :from_zip_code => '45440',
      :to_zip_code   => '20500',
      :weight_oz     => '6.5',
      :ship_date      => Date.today.strftime('%Y-%m-%d'),
      :package_type   => 'Package',
      :service_type   => 'US-FC'  # Flat-rate
    :to            => standardized_address,
    :from => {
      :full_name   => 'Littlelines',
      :address1    => '50 Chestnut Street',
      :address2    => 'Suite 234',
      :city        => 'Beavervcreek',
      :state       => 'OH',
      :zip_code    => '45440'


That's it! Stamps will return a url of the stamp. Print it and ship it!


If you are interested in more detailed information, check out the repo on Github.