Last Updated: September 09, 2019
·
808
· craigmcnamara

Send a Pull Request

A Clean Slate

I recently started porting some functionality from out mono-rail to a new Rails 4 app. I don't know what shape your front end code is, but the codebase I'm working on has 6 years of undocumented front end dependencies and hacked one off JS files. With a clean slate, I decided I'd see what had changed in the mean time to make managing JS libraries possible.

Bower

So if you come from Rails, Bower is like RubyGems for front end JS. Bower doesn't care about lots of the implementation details of the module so you can use it with most popular libraries now and if you can't, it's a fork or pull request away.

What I found was a Rails plugin called bower-rails that had Rake tasks to manipulate Bower and even provide a Gemfile like DSL called Bowerfile so Rails users wouldn't having to author a .json dependencies file.

So I installed it, added my Bowerfile file and ran rake bower:install and it didn't work.

WTF is going on?

Read the Code

So things didn't work, but luckily I'm a programmer. I opened up the code which was well organized but lacking tests so looked for the things that didn't seem right and started writing some tests based on the README. In the course of one hour I wrote some tests, found the bug that was hanging me up, fixed it and sent a pull request.

I have a private gem server so I was able to cut a gem, deploy and move on, but there is a pull request waiting here - https://github.com/42dev/bower-rails/pull/38 so things are a bit better for the next person to come along and want to use Bower to manage their JS libraries in Rails.

Links

Bower Homepage: http://bower.io/

bower-rails source: https://github.com/42dev/bower-rails

bower component directory: http://sindresorhus.com/bower-components/

Geminabox: https://github.com/geminabox/geminabox