RubyMinimumVersion

RubyMinimumVersion finds a minimum required version of ruby for Ruby code.

RubyMinimumVersion takes Ruby source code and calculates the minimum version of ruby required to be able to run it. Because it is based on the parser gem, it can do this without having to actually load the code. This gem is inspired by the Perl::MinimumVersion. This gem provides rubyver executable for the counterpart of perlver.

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add ruby_minimum_version

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install ruby_minimum_version

Usage

./exe/rubyver test/sample.rb
# Searching for Ruby files... found 1 file(s)
# Scanning test/sample.rb... done
# 21

Or more verbosely:

./exe/rubyver --verbose test/sample.rb
# Searching for Ruby files... found 1 file(s)
# Scanning test/sample.rb...
# Parsing with version 18...
# error: unexpected token tCOLON
# def a(b:); end
#        ^
# Parsing with version 19...
# error: unexpected token tLABEL
# def a(b:); end
#       ^^
# Parsing with version 20...
# error: unexpected token tRPAREN
# def a(b:); end
#         ^
# Scanning done
# 21

See also --help output.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome.