What you'll learn

  • How to Build a Ruby Gem

    The book will guide you through the process of how to build a Ruby Gem. From bootstrapping the project to releasing to RubyGems.org, you're only a few steps away from publishing a Ruby gem.

  • Rails Integration

    Rails provides a variety of lifecycle hooks to integrate functionality in to the framework, but not all of these hooks are well documented. We'll cover the basics to get you started creating gems that include view helpers, asset inclusions, and shared Active Record scopes.

  • Open source collaboration

    Managing and contributing to an open source project can be complex. This guide will help you manage the expectations and collaboration of a successful open source project.

  • Configuration Patterns

    Whether it's configuration patterns or testing best practices, writing code for a Ruby gem is unique. You'll learn techniques to manage and minimize this complexity for good.

  • Modular Ruby code

    The file conventions used within a Ruby gem are common to well organized Ruby applications. The guide will address best practices related to loading dependencies and testing modular Ruby code.

  • Increased Understanding of Bundler

    Bundler is a powerful gem that allows Ruby developers to easily mananage dependencies. Learn about some lesser known features of Bundler to help you ease the pain of common Ruby gem maintenance tasks.

Build a Ruby gem is an absolute gem! It is a great intro to the open source world and Ruby gem patterns. Both beginner and advanced programmers will learn something new.
Jearvon Dharrie
Jearvon Dharrie
Rubyist & Philly.rb organizer
I found Build a Ruby Gem to be a really useful resource in understanding how gems work and how best to build them. In particular I thought there was a lot of good "real world tips" to make the process go more smoothly.
Rory McCune
Rory McCune
Director at ScotSTS Limited
Build a Ruby Gem is a well-written and comprehensive book about creating Ruby gems the right way. Brandon's book is the best resource available to strengthen your Ruby Gem foo.
Andy Wenk
Andy Wenk
Rubyist & Project Lead at sum.cumo
Build a Ruby Gem gave me useful information not only about how to create a gem, but other information like semantic versioning, committing to open source projects and well-structured Ruby code. Without reading this book, I wouldn't have gotten in to building Ruby gems.

Chapter List

  • 1 - Introduction
  • 2 - Structure
  • 3 - Testing
  • 4 - Code
  • 5 - Release
  • 6 - Versioning
  • 7 - Changelog
  • 8 - Responsibility
  • 9 - Loading
  • 10 - Command-line Executables
  • 11 - Configuration Patterns
  • 12 - Rails Hooks
  • 13 - Rails View Helpers
  • 14 - Rails Controller Includes
  • 15 - Rails Model Includes
  • 16 - Rails Rake Tasks
  • 17 - Rails Generators
  • 18 - Rails Engines (sample chapter)
  • 19 - Open Source Projects
Build a Ruby Gem packages

Everything you need to start building Ruby Gems!

Learn the conventions and best practices of build a Ruby gem and launch your open source career today.

The book is 19 chapters, totaling 125 pages. Its content ranges from how to get started with open source projects to the nitty gritty of configuration patterns in a Ruby gem.

The complete package includes 14 screencasts totaling over 2 hours of video content detailing my workflow. I go through the process of writing the code for each technical chapter and discuss the benefits and downsides to various approaches.

Tweet about Build a Ruby Gem
Tweet about Build a Ruby Gem
Tweet about Build a Ruby Gem

Build a Ruby Gem Screencasts

Build a Ruby Gem Screencasts - Structure of a Ruby Gem Structure - Learn how files are organized within a Ruby gem and files necessary to be valid.
Build a Ruby Gem Screencasts - Testing and debugging setup Testing and Debugging Setup - Testing and debugging are necessary items for a robust Ruby gem. Learn what it takes to configure a setup that encourages testability.
Build a Ruby Gem Screencasts - Write code for our Ruby gem Code - In this lesson, we'll write the code for our example Ruby gem, learning how to load the necessary files along the way.
Build a Ruby Gem Screencasts - Releasing a Ruby Gem Release - a Ruby Gem isn't complete until it's available for use. We'll learn how to release a version of our Ruby Gem so others can use it.
Build a Ruby Gem Screencasts - Loading code from within a Ruby Gem Loading - In this lesson, we'll dig deeper in to loading files and learn how more complex gems are organized.
Build a Ruby Gem Screencasts - Building command line executables Command Line Executables - Ruby gems often come in the form of a command line executable. This is convenient when making command-line utilities. We'll find out what it takes to load your gem from the command-line.
Build a Ruby Gem Screencasts - Common configuration patterns in your Ruby Gem Configuration - It's rare when we can write code that will satisfy every use case. In this lesson, we'll look at common configuration patterns that will allow users of your Ruby Gem the ability to customize settings related to your gem.
Build a Ruby Gem Screencasts - Ingegrating common Rails hooks in your Ruby Gem Rails Hooks - Rails gives us lifecycle events that will allow us to integrate our code in to a Rails application. We'll dig in to what it takes to load our Ruby Gem in to Rails.
Build a Ruby Gem Screencasts - How to create Rails view helpers in your Ruby Gem Rails View Helpers - Adding Rails view helpers to an application can be a great first step in extracting logic from a complex application.
Build a Ruby Gem Screencasts - How to create Rails controller includes in your Ruby Gem Rails Controller Includes - Authentication libraries commonly provide methods to reference an authenticated user. In this lesson, we'll look at what's necessary to access code from our Ruby Gem as a method from a Rails controller.
Build a Ruby Gem Screencasts - How to create Rails model includes in your Ruby Gem Rails Model Includes - Model includes are helpful when we extract database access and analytical queries. In this lesson, we'll explore integrating our code in to ActiveRecord.
Build a Ruby Gem Screencasts - How to integrate Rake tasks into Rails from your Ruby Gem Rails Rake Tasks - Rake tasks are a great way to initialize the installation/configuration step of a Ruby gem. This lesson will cover what's necessary to access code from our gem within a Rake Task.
Build a Ruby Gem Screencasts - How to include Rails generators in your Ruby gem Rails Generators - Rails generators give us tasks like Rake tasks that we can run to initialize configuration templates for our Ruby Gem.
Build a Ruby Gem Screencasts - How to include a Rails engine in your Ruby gem Rails Engines - As the deepest integration, we'll find out what it takes to build a Rails Engine giving our Rails application access to code from our Ruby Gem.

Choose the package that's right for you

Basic Package

$ 59 59 44

  • 125-page Book w/ updates
Buy now

Complete Package

$ 129 129 99

  • 125-page eBook w/ updates
  • 14 screencasts (over 2 hours)
Buy now

Coaching Package

$ 299 299 249

  • 125-page eBook w/ updates
  • 14 screencasts (over 2 hours)
  • 1-on-1 coaching session (1-hour)
  • Access to private Slack community
Buy now
Building Ruby gems is intimidating. It seems impossible to find the right documentation when you need it. Most of the information out there assumes that you already know what you’re doing. And there’s never been a great guide to get started.

Build a Ruby Gem will teach you all of that, in a short, simple, totally approachable guide. It’s the most information about building gems I’ve ever seen in one place, and I can tell I’ll be opening it back up whenever I have a question about a gem I’m building.

Even if you’ve been creating gems for years, you’ll *still* learn a ton from Build a Ruby Gem. I certainly did.
Justin Weiss
Justin Weiss
Rubyist and Author of Practicing Rails
I recently ran into an issue at work where we needed to use one of our custom Rails generators in another project. I knew the best way to accomplish this was with a gem, but, I'd never built a gem before and felt pretty intimidated.

While researching how to build a gem, I came across Brandon’s book, "Build a Ruby Gem". Feeling overwhelmed by the task at hand, I took a chance and purchased a copy. It was worth every penny.

Brandon's book is clear, well organized, easy to follow and comprehensive. I was able to breeze through the book while following his sample code to build - and publish - my gem in just one day!
Craig Kaminsky
Craig Kaminsky
Senior Application Developer at HomeActions

About the Author

My name is Brandon Hilkert and I've been feverishly building Ruby applications since 2009.

I first got started with open source Ruby gems by contributing to Sidekiq. Since then I've written about contributing to Open Source software and written few gems myself, most well-known — Sucker Punch.

When I attempted to write my first gem, I was pretty confused about the standards and conventions necessary to integrate with existing Ruby tooling. Since then, I've learned a lot and shared it with 900+ other Rubyists through a FREE email course. Based on feedback from the course, I decided to write a book. I hope you enjoy it.

Build a Ruby Gem eBook Cover


  • What formats do you support?

    The book ships with .pdf, .epub and .mobi formats. All screencasts are .mp4.

  • What if I hate it?

    If you feel that strongly, I'm happy to issue a refund within the first 30 days.

  • Can I read a sample chapter?

    Of course! There's one linked above in the chapter list.

  • You didn't answer my question...

    Email me or get me on Twitter and I'll do my best to get your questions answered.