require 'rubygems' #gems are stored in a hash with the key set to the name of the gem and the value is the version. #the trick is to get the hash to an array and join the version number to the gem name. #Feedback appreciated. def local_gems Gem::Specification.sort_by{ |g| [g.name.downcase, g.version] }.group_by{ |g| g.name } end puts local_gems.map{ |name, specs| [ name, specs.map{ |spec| spec.version.to_s }.join(',') ].join(' ') }
puts `gem list`- require 'rubygems'
- #gems are stored in a hash with the key set to the name of the gem and the value is the version.
- #the trick is to get the hash to an array and join the version number to the gem name.
- #Feedback appreciated.
- def local_gems
- Gem::Specification.sort_by{ |g| [g.name.downcase, g.version] }.group_by{ |g| g.name }
- end
- puts local_gems.map{ |name, specs|
- [
- name,
- specs.map{ |spec| spec.version.to_s }.join(',')
- ].join(' ')
- }
# TODO: Replace examples and use TDD development by writing your own tests # These are some of the methods available: # Test.expect(boolean, [optional] message) # Test.assert_equals(actual, expected, [optional] message) # Test.assert_not_equals(actual, expected, [optional] message) describe "Solution" do it "should test for something" do Test.assert_equals("actual", "expected", "This is just an example of how you can write your own TDD tests") end end
- # TODO: Replace examples and use TDD development by writing your own tests
- # These are some of the methods available:
- # Test.expect(boolean, [optional] message)
- # Test.assert_equals(actual, expected, [optional] message)
- # Test.assert_not_equals(actual, expected, [optional] message)
- describe "Solution" do
- it "should test for something" do
- Test.assert_equals("actual", "expected", "This is just an example of how you can write your own TDD tests")
- end
- end