Updating Installed Gems
Author: Samuel Williams When: Thursday, 29 April 2010April 2009
May 2009
August 2009
September 2009
October 2009
- Building a Concrete Bath
- LED Lighting Comparison
- Thinking about Programming Languages
- How To Be A Consultant
- Lucid Programming Dojo
- Exim4 + ClamAV + SpamAssassin
- Secure login using AJAX
- Ramaze And Rack
- ActiveMerchant
- Concurrency And Immutability
- Floating Point Numbers
- Programming And Debugging
- Useful jQuery Plugins
- Loading Anonymous Ruby Classes
- 尺八 (Shakuhachi)
- Card Trick
- Object Oriented C
- Gemcutter
- Writing Clearly
- Richard Stallman In Christchurch
- Magnatune
- Client Side Graphing
- Zena CMS
November 2009
February 2010
March 2010
April 2010
May 2010
June 2010
July 2010
August 2010
September 2010
December 2010
January 2011
March 2011
May 2011
August 2011
September 2011
I recently had to upgrade DataMapper which has lots of separate gems for different bits of functionality. Rather than typing them all in manually, I wrote a one-liner to do it. Firstly, we have a list of gems on the computer, and then we grep for "dm":
-- Print out a list of local gems Nekomimi:~ samuel$ gem list *** LOCAL GEMS *** abstract (1.0.0) actionmailer (2.3.5, 2.2.2, 2.1.0, 1.3.6) actionpack (2.3.5, 2.2.2, 2.1.0, 1.13.6) actionwebservice (1.2.6) -- And hundreds more.... Nekomimi:~ samuel$ gem list | grep dm dm-adjust (0.10.2, 0.10.1) dm-aggregates (0.10.2, 0.10.1) dm-ar-finders (0.10.2, 0.10.1) dm-cli (0.10.2, 0.10.1) dm-constraints (0.10.2, 0.10.1) -- And lots more...
So we have a list of gems.. but we need to remove the version number brackets (0.10.2, 0.10.1). To do this there are a number of options, but we will use sed:
-- Remove the trailing brackets using sed (Stream EDitor) Nekomimi:~ samuel$ gem list | grep dm | sed -E "s/\(.*\)//" dm-adjust dm-aggregates dm-ar-finders dm-cli dm-constraints dm-core -- And lots more... # This prints the command we are want to run: Nekomimi:~ samuel$ gem list | grep dm | sed -E "s/\(.*\)//" | xargs echo sudo gem install sudo gem install dm-adjust dm-aggregates dm-ar-finders dm-cli dm-constraints dm-core dm-is-list dm-is-nested_set dm-is-remixable dm-is-searchable dm-is-state_machine dm-is-tree dm-is-versioned dm-is-viewable dm-migrations dm-more dm-observer dm-querizer dm-rest-adapter dm-serializer dm-shorthand dm-sweatshop dm-tags dm-timestamps dm-types dm-validations dm-yaml-adapter -- Here is the command actually running: Nekomimi:~ samuel$ gem list | grep dm | sed -E "s/\(.*\)//" | xargs sudo gem install Successfully installed dm-adjust-0.10.2 Successfully installed dm-aggregates-0.10.2 Successfully installed dm-ar-finders-0.10.2 -- And lots more...
Comments
Please note, you can leave a comment that uses (limited) XHTML and Textile syntax.