Ask A Question

Notifications

You’re not receiving notifications from this thread.

Making a gem like thoughtbot's refills gem

Josh Sandlin asked in Gems / Libraries

Heya,

I saw on HN the other day that USDS has released a styleguide/component system based off of Bourbon. I'd like to toy around with making a gem based off of the Refills gem that allows me to list out components and then "import" them (sticking their styles, erb templates, and js into a directory in app/assets).

Initially I was just going to fork the Refills gem and swap out the assets it generates, but I'm still relatively new to Rails, and I can't see the forest for the trees there. I know logically what it's doing, but everything seems very well connected to how they have things organized.

Would it be worth while to migrate the USDS assets to a "form-factor" that agrees with the Refills gem layout, or to try and roll my own using the USDS "form-factor".

Ideally, I'd like to just be able to type "rails generate wds:list" and then rails generate wds:import SNIPPET" like I can do with Refills.

I hope that makes sense.

Reply

Hey Josh,

I would love to see this! I think what you're looking for is learning how to create generators that install things from a gem. I've been building the simple_calendar gem and made an episode on how you can create generators that should be helpful. https://gorails.com/episodes/vlog-day-13?autoplay=1

The next step after you get a basic generator done is to take a look at the refills gem and see how they build the "import" generator. I'm not entirely sure, but it should be a good basis on how to do that. I've yet to dive into any of the USDS styleguides, but this would be a really really cool gem to make and should help adoption of it a lot. You'd be famous if you get this built. :)

Reply

Thanks!

I've given myself some motivation to get this going by entering it into this year's Octobuild (http://octobuild.com/) (https://github.com/dydx/usds-wds).

So far it sort of works, though I've still got a few weeks to iron out the kinks.

Reply

Octobuild sounds like an awesome idea! I hadn't heard of it. Thanks for sharing that!

Also awesome start to the USDS project! It looks great so far. Nice and simple. :)

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 76,990+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2023 GoRails, LLC. All rights reserved.