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.
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.
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.
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
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.
Build a Ruby Gem Screencasts
Structure - Learn how files are organized within a Ruby gem and files necessary to be valid.
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.
Code - In this lesson, we'll write the code for our example Ruby gem, learning how to load the necessary files along the way.
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.
Loading - In this lesson, we'll dig deeper in to loading files and learn how more complex gems are organized.
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.
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.
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.
Rails View Helpers - Adding Rails view helpers to an application can be a great first step in extracting logic from a complex application.
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.
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.
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.
Rails Generators - Rails generators give us tasks like Rake tasks that we can run to initialize configuration templates for our 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
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.
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!
Questions?
-
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.