I was thinking about integrating a little feature into my CMS that checks for new releases of the gems that are installed. Is there a way to check the current installed version of a Gem from within the application/rails console?
In theory, you can access the rubygems api via the Gem
class:
Gem.latest_version_for "pry"
# => Gem::Version.new("0.9.12.6")
To get the list of current gems, you can try this.
gems = Gem::Specification.sort_by{ |g| [g.name.downcase, g.version] }.group_by{ |g| g.name }
gems["pry"].version
# => Gem::Version.new("0.9.12.4")
Blatantly stolen from here.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.