Freeze (vendor, unpack) a single Ruby gem with and without Bundler
When you need to patch an existing gem, one way is to "vendor" the gem by copying it into the vendor/gems
directory of your Rails project. You can then make any changes you require and Rails will use the vendored version of the gem after a server restart. Unfortunately you need to perform some additional steps to marry Rails and the copied gem. This notes describes what to do.
With Bundler
This is super-painful. If you just copy the gem to vendor/gems
, Rails will complain:
Unpacked gem foolib in vendor/gems has no s...
How to install the date_performance gem
sudo gem install zip
git clone git://github.com/rtomayko/date-performance.git
cd date-performance
rake package:build
cd dist
sudo gem install --no-ri --no-rdoc date-performance-0.4.7.gem
Install a gem without RI and RDdoc
To improve installation times of gems you can use the following approach:
gem install xyz --no-document
To permanently ignore ri
and rdoc
when installing gems, add this line to ~/.gemrc
:
gem: --no-document
Be aware that eliding local documentation may disable documentation support in your IDE.
Create an application with an older Rails version
sudo gem install rails --version="=1.2.3"
rails _1.2.3_ new-project-folder
Slugs with FriendlyId
Gem to provide nice looking urls ("/blog/the-greatest-bug-i-never-fixed"). If you don't need anything too special (like i18n for the urls) it works as a drop-in-replacement. It basically overwrites #to_param
to return the slug, and .find
to search by the slug.
Make sure, everywhere you build paths, you use model_path(:id => model)
instead of model_path(:id => model.id)
. You also need to adapt all code using something like .find_by_id
. The regular .find
is fine.
See the github README for installation instructions.
Don't forget ...
Railscheck project home page
This project is (or will be) a best effort semi-static verifier for your Ruby on Rails projects. Delivered as a Ruby gem it provides a shell command task "railscheck" that you can run against your Rails projects to test for a number of typical bugs, potential problems and inconsistencies.
bundle-fu - Google Code
Web 2.0 sites have lots of tiny javascript/css files, which causes one extra round trip per file to the server and back! This is bad! Bundle-fu throws it all up into a big package and sends it out all at once.
The Exciter - Why You Should Deploy Your Next Application on Ruby 1.9 and a Rant in General
The rubyforge gems model may not be perfect, but damnit people, when there’s a gem update I know that it has actually been tested somewhat and it’s not just whatever random point HEAD happens to be at, at that point in time, by some random Joe who just bought TextMate.
Sickill.net - Colorizing console output with Rainbow ruby gem
If you’re working on some cool ruby console-based application or just want to add a little style to your script here is a nice gem for you. It’s called Rainbow and it extends ruby String class adding methods to wrap the string with ANSI escape codes.
metric_fu: A Ruby Gem for Easy Metric Report Generation
Metric_fu is a set of rake tasks that make it easy to generate metrics reports. It uses Saikuro, Flog, Flay, Rcov, Reek, Roodi, Subversion, Git, and Rails built-in stats task to create a series of reports. It's designed to integrate easily with CruiseControl.rb by placing files in the Custom Build Artifacts folder.
Pennysmalls
I just released a gem to find image dimensions and type information fast.
Basement.org: On The Web, More Isn’t Only Less, It’s Actually Nothing
Amidst my 400 unread Boing Boing links are probably ten or fifteen that are probably real gems. But I’ll never know and Boing Boing sure as hell isn’t going to help me out.
Learning from the iPhone's failure as a gaming platform: gem-session.com blog
If we want mobile applications to stay around as a sustainable business, we need to be more honest about the strengths and weaknesses of a touchscreen UI, rather than salivating about an imaginary realm of unnamed possibilities.
From Bundler to Open and Inclusive Software Communities : Steven R. Baker
Though we ended up switching to what I consider to be a technically superior product based on simplicity, we arrived there because of poor community interaction on the part of the Bundler developers.
How to split a Ruby class into multiple source files - Gem Session
Unfortunately vanilla Ruby modules lack support for many idioms popular in modern Ruby. Most importantly, we have become accustomed to composing our classes with meta-programming macros such as has_many, validates_presence_of or after_save. And modules weren't built with macros in mind.
Never write a Cucumber step definition again with Cucumber Factory - Gem Session: gem
I love Cucumber, but I hate writing step definitions. They are ugly, awkward to write and very, very boring: Most step defintions merely create objects for a scenario to chew on.
michaeldv's awesome_print at master - GitHub
Pretty print your Ruby objects with style -- in full color and with proper indentation
The greatest bug I never fixed - Gem Session
When I realized what had gone wrong, the light almost blinded me.
Why I won't help you - Gem Session
But then there are those posts where the author pastes 10 pages of confused code with no context whatsoever and then demands to know why they're getting funny errors. I find this sort of behaviour offensive to all the people who are basically dealing out free support. I'd rather spend my time helping people who actually give a damn.
Will Rails 3 obstruct plugin innovation? - Gem Session
Where there was once a consistent API to manipulate and hook into the lifecycle of a persistent object, plugins must now perform very careful checks whether an object supports more advanced traits like transactions, observers or dirty attribute tracking.