Q:

How do you check the Gem Version in Ruby at Runtime?

Is it possible to check the gem version of the currently loaded gem in a ruby/rails app?
During debugging, I would like to be able to do something like:
puts RubyGem.loaded_version(:active_support)

Anything like that exist?

A:

puts Gem.loaded_specs["activesupport"].version

A:

careful when comparing against Gem.loaded_specs['mini_magick'].version as it's not a String but a Gem::Version object !
the version string is accessible using Gem.loaded_specs['mini_magick'].version.version which is ugly and might not work as expected e.g. '2.2' > '2.10' !
the correct way to compare against a gem version is :
Gem.loaded_specs['mini_magick'].version < Gem::Version.create('2.0')

