In 1.8 you need to `require 'rubygems'` first, I think.

2012/10/11, Sam Duncan <sduncan / wetafx.co.nz>:
> On 10/11/2012 06:10 PM, Abhishek K. wrote:
>> Thanks.
>>
>> I want this in ruby code.
>>
>> above is not working for ruby1.8.7 but working for 1.9.2, is there any
>> way whichworks for all versions of ruby?
>>
>>
>> ruby-1.8.7 -e 'puts Gem::Specification.all().map{|g| [g.name,
>> g.version.to_s] }'
>> -e:1: uninitialized constant Gem (NameError)
>>
>>
>> ruby-1.9.2 -e 'puts Gem::Specification.all().map{|g| [g.name,
>> g.version.to_s] }'
>> NOTE: Specification.all called from -e:1:in `<main>'
>> minitest
>> 1.6.0
>> rake
>> 0.8.7
>> rdoc
>> 2.5.8
>> ruby-graphviz
>> 1.0.8
>> ruby-oci8
>> 2.1.2
>> rubygems-update
>> 1.8.24
>> sequel
>> 3.37.0
>>
>
> Try running it like this;
>
> ruby-1.8.7 -rubygems -e 'puts Gem::Specification.all().map{|g| [g.name,
> g.version.to_s] }'
>
> Sam
>
>

-- 
Wysane z mojego urzdzenia przenonego

-- Matma Rex