Open Source, Beer, and Ruby

I recently started homebrewing in the past two months. I can proudly say that I combined, hops, water, malt, and yeast together into one drinkable IPA and one on it’s way. Being a programmer and a bit rusty with my Ruby, I decided to build myself a brewing manager.

The Problem Space

The requirements were simple. I wanted a tile based dashboard that would list the states of my various brews with estimated completion times, and few helpful calculators and widgets to guide me along. Other websites do a decent job at providing tools, but I was getting sick of having 30 browser tabs open. I never anticipated the amount of work and research it would take to build one calculator. Calculating the amount of priming sugar you need to add to the beer.

See, when you make beer, if you don’t have a tool to force CO2 into your beer, you must let nature handle it. You do this by allowing the leftover yeast to eat sugar that you add to the batch before bottling. You cap off the beer. And bam! The yeast start carbonating your beer. However, you can use different types of sugar. Also, the temperature that your beer ferments at has an effect, and so many other variables that I never thought mattered.

The Open Source Community is Awesome and needs to Expand

I love the open source community. It’s full of more resources than one could ever dream of, well documented, and sorted, and searchable. It could take five minutes to solve problems that could plague you for days. Compared to the rest of the world though, we live in a fantasy land.

Much of the information on homebrewing is spread across forums, various recipes online using different measurements, wikis with conflicting information, videos from brewers, etc. There is no common source of truth, or even a platform to discuss that common source of truth.

For example, how great would it be to have one location where a mathematical formula is listed for brewing. A place where it can be moderated and versioned for different edge cases, like with software and Git. It took hours of research, digging through wikis, sifting through online textbooks, recipes, blog posts, and more before I could safely say that my code was good enough to get by on. ( Still off by a gram for now ).

It astonishes me that with the large number of highly technical brewers, that there isn’t some sort of standard written around how very low level common things are done. Maybe it takes some of the spontaneity out of the process?

The code

class PrimingSugarCalculator
class << self

def priming_sugar(args)
temperature = args[:temperature]
gallons = args[:gallons]
co2 = args[:co2]
sugar_efficiency = args[:sugar_efficiency]

pure_sugar_volume = 15.195 *
gallons *
( co2 - 3.0378 + ( 0.050062 * temperature ) -
( 0.0002655 * temperature ** 2 ) )

pure_sugar_volume / sugar_efficiency


This is far from perfect and conflicts with many other tables and calculators, but comes within a gram of being correct which is good enough for my purposes. Yet, I know that this isn’t good enough for more serious brewers and brewers working on much larger scales than I. I have little experience in brewing and math, but I know how to code and what my experience. I plan to open source this as a gem and let peer review take over. My hope is that over time we can have a wide collection of very specific brewing gems that can be given the attention the deserve.

Let’s work together to brew better beer and code.

Happy brewing fellow programmers!