How to access the version of a gem from within Ruby? -


how can version of gem using ruby? i'd rather not use system call , grep shells output like:

`gem search passenger`.scan(/(?:\(|, *)([^,)]*)/).flatten.first => "2.2.9" 

can't somehow with:

gem::version 

i don't know how specify gem want, in case want passenger gem's newest version.

this should on way. searches remote index latest version of specific gem.

$ irb >> require "rubygems" >> dep = gem::dependency.new "passenger", gem::requirement.default >> gem::specfetcher.fetcher.find_matching dep => [[["passenger", #<gem::version "2.2.9">, "ruby"], "http://gems.rubyforge.org"]] 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -