Rootstrap Blog

Why creating a gem is a great thing to do

What is a Gem and Why build one?

Gems are libraries of code that add functionality to projects. That code can add features to the product, help improve the quality of the code, or help build software faster. And why should you build a gem? Because publishing a gem that resolves a real-life problem is a great way to contribute to the Ruby community.

And the Ruby Community is AMAZING.

It is large and vast and works together with the aim of creating beautiful software of high quality and with a fast output.

Members of this community contribute in different ways from discussing improvements in the language to creating solutions to both familiar or not so well-known patterns.

In short: they develop software that helps other people with similar problems.

And one way of the best ways to contribute to the Ruby community is through gems.

A Real-Life Example with ActiveAdmin

ActiveAdmin is a popular Ruby on Rails gem that provides a simple and quick way of generating an administration website.

What did we create?

We saw something missing within this popular gem. So we created an out-of-box chat function for ActiveAdmin called ActiveAdminChat.

So, what does this gem do?

As the names implies, this gem adds an admin chat that allows users to directly communicate with admins through a private channel (using ActionCable). This chat is built over Rails and ActiveAdmin – two major gems already existing in the Ruby ecosystem.

We built this gem following the ActiveAdmin approach so that with a few additional configurations, anyone can access the most difficult part of the solution.

The first version of the chat is displayed using the default ActiveAdmin style but can easily be customized. Then, for sending messages we use the well-known data-interchange format JSON which makes it easier for developers to use the gem across various clients, whether it be for mobile or web apps.

The Roadmap

There was some initial doubt surrounding when to release the first version as there is always room for improvement. Ultimately, we decided to push for an early first release of the gem and then iterate, which allows us to improve the gem through all of the insight we gather.

There is still a bit to improve with the gem. There are some features we are already thinking of adding like being able to choose whether users will communicate with admins immediately or not, being able to configured time format, etc. But for now, we’ve determined we have a great start for the first release of the ActiveAdminChat gem.

Keep it simple. Keep it lean. That’s our ethos.

Just like any other project, we also had to maintain the quality of the code we are developing. We had great code coverage and great maintainability but still needed to make the project work for several gem version combinations.

We cannot test with all combinations of the gem, but through an early public release, we now have the advantage of developers from all over the world using it and contributing to making the code more robust.

Grand Finale

Developing software for everyone is a great way to both contribute to the coding community and learn from that community as well. The Ruby community continues to be generous and friendly and working together ultimately benefits us all.

This is the result of our initial work: https://github.com/rootstrap/active_admin_chat/

Feel free to ask any questions or even fork at your discretion. Hit me up at federico@rootstrap.com if you’d like to discuss further.

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.