Is there a clean way to extract the version string from a .gemspec file? (The gem is not yet installed)
e.g. somethingcool.gemspec is
Gem::Specification.new do |s|
s.name = "somethingcool"
s.version = "1.2.3"
... etc ...
end
I want to extract "1.2.3".
I could grep it out but there must be a better way.
You can check your Ruby version by running ruby --version , and you can check your RubyGems version by running gem --version . If you need to upgrade Ruby, use your ruby version manager's instructions. If you need to upgrade RubyGems, run gem update --system .
Developer file that specifies the attributes of a RubyGems . GEM package; saves information such as the author, a description, an example usage, and the usage license; saved in a simple plain text format.
Use `gem install -v` You may already be familiar with gem install , but if you add the -v flag, you can specify the version of the gem to install. Using -v you can specify an exact version or use version comparators.
require "rubygems"
spec = Gem::Specification::load("example.gemspec")
puts spec.version
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With